G Guest Sep 1, 2007 #2 What's the context? Is it in a formula? You can use ISEMPTY in VBA to test for empty cells. Barb Reinhardt
What's the context? Is it in a formula? You can use ISEMPTY in VBA to test for empty cells. Barb Reinhardt
D Dave Peterson Sep 1, 2007 #3 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
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
D Dave Peterson Sep 2, 2007 #4 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.
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.