#Name for user function

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
Hi,
It should be
Public Function Test() As Double
Test=1
End Function

Kind Regards.
--
Haldun Alay
"donty" <[email protected]>, haber iletisinde ÅŸunları yazdı:[email protected]...
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?
 
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 >
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top