Calling a function in excel

  • Thread starter Thread starter Tom
  • Start date Start date
T

Tom

I created a function in the Visual Basic Editor in Excel
but am unable to call it from an individual cell in
Excel. I am using "=function name(argument1, argumaent2,
argument3)" when I try to call it. I am getting the
error "$NAME?". Any ideas?
 
Hi

The function should be i a standard module (insert menu), not in a worksheet
module or anywhere else. And it must not be Private as in
"Private Function XYZ() as Long"
And you are of course entering it without the quotes ?
 
I don't see the option insert menu. Am I in my Excel
spreadsheet when I create this function?
 
No, in the VB editor.

For a quick test: In a blank workbook, open the VB editor (Alt F11 or similar). Go menu
Insert > Module. Paste this in it:

Function Half(D As Double) As Double
Half = D / 2
End Function

Now close the editor, return to Excel. Enter a number in cell A1. In B1 enter this:

=Half(A1)

and -in theory- it should work.
 
Very clever Harald,
and coming from a Yorkshireman that is praise indeed!

Thanks


John P
 
Back
Top