Returning an empty/blank cell value

1,060 views
Skip to first unread message

sp

unread,
May 2, 2009, 6:42:59 PM5/2/09
to ExcelDna
Is there any way to return an empty/blank cell (not 0 and not an empty
string) in ExcelDna? I know there is directly in C, but I can't
manage to do it in ExcelDna -- i.e. both ExcelEmpty.Value and
ExcelMissing.Value show up as 0.

Govert van Drimmelen

unread,
May 3, 2009, 2:53:10 AM5/3/09
to ExcelDna
Hi,

As far as I know, the behaviour of ExcelDna is exactly the same you'll
have in C. When you return a ExcelEmpty or ExcelMissing from your
function, I correctly build the corresponding XLOPER and return it to
Excel. If you return a null, a null pointer is returned directly to
Excel. So your function controls exactly what Excel receives,
equivalent to what you could return directly in C.

However, as long as a cell has a formula in, Excel will never consider
the cell to be empty. If the result of your function is ExcelMissing
or ExcelEmpty, Excel will evaluate the result as a 0, while a null is
converted to a #NUM error. So you have to return an empty string to
get a cell that is displayed as empty. Of course you can clear a cell
from a macro.

I'd be happy to look at it again if you can explain how to do so
'directly in C'.

Regards,
Govert

sp

unread,
May 3, 2009, 5:55:47 PM5/3/09
to ExcelDna
Thanks, Govert.

I may well have been incorrect about being able to return a blank cell
from C. Unfortunately I no longer have access to the code that I
think did this, so I'm probably misremembering.

I guess the functionality I would like is to be able to return
ExcelEmpty.Value, and have it show up as an empty string. But the
reason I don't want my functions to return an empty string directly is
that I'd like to be able to call them from other functions and be able
to differentiate. I guess it's just unfortunate that Excel doesn't
allow for an empty value that displays as a blank.
> > ExcelMissing.Value show up as 0.- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages