#VALUE errors


Posted by gary on January 29, 2002 9:26 AM

I'm lost, I'm trying to set the contents of a cell in vba

Here's the function:

Public Function aa()
Cells(5, 1).Value = 999
aa = 0
End Function

It always returns a #VALUE error when called.

If I comment out the Calls statement, it returns 0

this is excel 2000

I've tried samples directly from the help files, and always get the #VALUE error when trying to set the contents of a cell

Gary



Posted by Larry Kramer on February 10, 2002 5:58 PM

if you want the cell to have the formula "=aa()":

Public Function aa()

aa=999

end function

You should not try to stuff a cell with a command in a function; all a function can do is return a value that will substituted for the function call in the cell's formula.

The cells(5,1)=999 command belongs in a SUB, not a function.

Or am I missing something?