Does IsMissing only work with Variants?

P

Prof Wonmug

If I code a Function statement

Function Temp(Optional abc As Single)

then calling the function with no arguments

=temp()

[abc] gets assigned the value "0" and the IsMissing(abc) test always
fails. If I change the Function statement to

Function Temp(Optional abc)

then everything works.

Is there no way to have an optional numeric argument and be able to
assign the default in the function?
 
P

Prof Wonmug

Methinks someone did not read the help files for IsMissing... <g>

When I click on the Help button from the VBA IDE, I get "This page is
not available". It's been that way for quite a few days.

I also searched online for "VBA IsMissing" and "VBA Optional
Arguments" and a few others. I could not find anywhere that it
mentioned anything about IsMissing and datatypes.

I finally found something on VB.Net (which I am not running) about
IsMissing not being supported and it showed an example of assigning a
default value on the Function statement:

Function Temp(Optional abc As Single = 1)

That fixed the problem.

Thank you so much. You have been very helpful....not
 

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

Top