how do I express the term if x is integer in VBA language?

excel34 picture excel34 · Jan 2, 2010 · Viewed 72k times · Source

how do I express the term if x is integer in VBA language ? I want to write a code that does something if x is integer and does something else if its not with vba excel.

Sub dim()
  Dim x is Variant

  'if x is integer Then 

  'Else:

End Sub 

Answer

shahkalpesh picture shahkalpesh · Jan 2, 2010
If IsNumeric(x) Then 'it will check if x is a number

If you want to check the type, you could use

If TypeName(x) = "Integer" Then