View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Calling a public function from a worksheet

UDF's need to be either in the workbook from which they are called or in an
addin. So your function won't work if in your Personal.xls (except of course
if called from personal.xls).

In passing, I'd change the "As Integer" to "As Long".

Regards,
Peter T

"JWirt" wrote in message
...
When I call this public function from a worksheet cell (e.g.,
=Nspaces(7)),
the result is #NAME?

Pulic Function Nspaces(NumSp As Integer)
Dim Nspaces1 As String
Nspaces1 = ""
While Len(Nspaces) < NumSp
Nspaces1 = Nspaces1 & " "
Wend
Nspaces = Nspaces1
End Function

Why?

I created this function in a separate module in Personal.xls.

Thank you.

John