Empty space as "zero"

  • Thread starter Thread starter Guest
  • Start date Start date
What's the context? Is it in a formula? You can use ISEMPTY in VBA to
test for empty cells.

Barb Reinhardt
 
Is there a way not to consider an empty CELL as a "0"?

Yes, just check.

dim myCell as range
set mycell = activesheet.range("a1")

if isempty(mycell.value) then
msgbox "It's empty!"
elseif isnumeric(mycell.value) then
msgbox "It looks like a number to VBA!"
end if

Another way:
if application.isnumber(mycell.value) then
'it's a some sort of number for sure
end if
 
Ps. VBA's isnumeric() behaves differently than Excel's =isnumber().

In excel, if you format a cell as text and then type 123 in it, then =isnumber()
will return False.

In VBA, if that string or value can be construed to look like a number, then
isnumeric() will return true.
 

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

Back
Top