View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
aushknotes aushknotes is offline
external usenet poster
 
Posts: 12
Default Calling a public function from a worksheet

Hi,

You have to put your function in a module. BTW you can simplify your
function as follow:

Function Nspaces(NumSp As Integer)
Nspaces = space(Numsp)
End Function

Cheers,






"JWirt" wrote:

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