Declaring variables

F

freekrill

Hi,

I want to declare a variable which can be either an integer or null.
What do I put in the dim x as ... statement?

Thanks for your help

free
 
F

freekrill

Thanks Chip,

I have tried that, but when I then try to sum two of the inputs, it
concatenates instead. A simple example of what I have tried is below.
Thanks for any comments

free

Sub test ()

Dim a as Variant
Dim b as Variant

a = InputBox("Enter A")
If a = "" Then a = 0
b = InputBox("Enter B")
If b = "" Then b = 0
c = a + b
Range("A1").Value = c

End Sub

When I run the macro and enter, say, 1 for A and 2 for B, I get the
value 12 in "A1", rather than 3 which is what I want.
 
Top