ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   #Name for user function (https://www.excelbanter.com/excel-programming/313513-name-user-function.html)

donty

#Name for user function
 
I have written a function on the code for a sheet in my workbook eg

Public Function Test() As Double
return 1
End Function

However when I try to use it in a cell in my sheet like this =Test() I get a
#Name error.

What am I doing wrong?



Jean-Yves[_2_]

#Name for user function
 
Hi,

Put you Function in a standard module.
Regards,
Jean-Yves

"donty" wrote in message
...
I have written a function on the code for a sheet in my workbook eg

Public Function Test() As Double
return 1
End Function

However when I try to use it in a cell in my sheet like this =Test() I get

a
#Name error.

What am I doing wrong?





Haldun Alay[_4_]

#Name for user function
 
Hi,
It should be
Public Function Test() As Double
Test=1
End Function

Kind Regards.
--
Haldun Alay
"donty" , haber iletisinde şunları ...
I have written a function on the code for a sheet in my workbook eg

Public Function Test() As Double
return 1
End Function

However when I try to use it in a cell in my sheet like this =Test() I get a
#Name error.

What am I doing wrong?



keepITcool

#Name for user function
 
1.
change return 1
to Test = 1

2.
in VBE go to tools/options
and check the "require variable declarion" checkmark

this puts the line
OPTION EXPLICIT in the top of each new module
and will help prevent coding errors.

3. Buy a book on VBA. It's easy to learn, but a bit harder then getting to
work with excel. You'll need to study a bit..



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"?B?ZG9udHk=?=" wrote:

I have written a function on the code for a sheet in my workbook eg

Public Function Test() As Double
return 1
End Function

However when I try to use it in a cell in my sheet like this =Test() I
get a #Name error.

What am I doing wrong?






All times are GMT +1. The time now is 08:58 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com