![]() |
Empty space as "zero"
Is there a way not to consider an empty space as a "0"?
|
Empty space as "zero"
What's the context? Is it in a formula? You can use ISEMPTY in VBA to
test for empty cells. Barb Reinhardt "Barbicane" wrote: Is there a way not to consider an empty space as a "0"? |
Empty space as "zero"
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 Barbicane wrote: Is there a way not to consider an empty space as a "0"? -- Dave Peterson |
Empty space as "zero"
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. Dave Peterson wrote: 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 Barbicane wrote: Is there a way not to consider an empty space as a "0"? -- Dave Peterson -- Dave Peterson |
All times are GMT +1. The time now is 10:55 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com