Calling a public function from a worksheet
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 |
Calling a public function from a worksheet
You have Pulic Function!
try... Public Function -- Regards, Nigel "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 |
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 |
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 |
Calling a public function from a worksheet
try:
=personal.xls!nspaces(7) (and fix the public typo) or use: =rept(" ",7) 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 -- Dave Peterson |
Calling a public function from a worksheet
"Peter T" <peter_t@discussions wrote in message
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 -er, unless of course you fully qualify the function in cell formulas along the lines as suggested by Dave Regards, Peter T |
All times are GMT +1. The time now is 12:24 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com