« Return to Thread: Custom cell function - how to detect empty cell?

Custom cell function - how to detect empty cell?

by Johnny Rosenberg :: Rate this Message:

Reply to Author | View in Thread

Function MyFunction(A As Variant) As Variant
   Dim Something As Variant

   REM Lots of stuff here…
   MyFunction=Something
End Function

Using it in a cell:
=MyFunction(A1)

So A should be the content of the cell A1 in this case. However, if A1
is empty, A ends up as a double with the value 0. This makes it quite
impossible to detect wether a cell is empty or not, doesn't it? At
least I can't find a way to do that.

Well, I have a theory, which I didn't test yet:
Let's say that I just entered a custom cell function in cell B45. Can
I be sure that B45 is the currently active cell when the function
runs? Even if B45 is only one of a lot of cells that are calculated
when autofill is performed? If so, I could just check the
ActiveCell.getValue() and ActiveCell.getString() after first creating
the object ActiveCell, of course, right?

Johnny Rosenberg

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@...
For additional commands, e-mail: dev-help@...

 « Return to Thread: Custom cell function - how to detect empty cell?