Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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  
like image 631
excel34 Avatar asked Jan 02 '10 21:01

excel34


2 Answers

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 
like image 150
shahkalpesh Avatar answered Sep 26 '22 00:09

shahkalpesh


This may suit:

If x = Int(x) Then 
like image 26
Fionnuala Avatar answered Sep 26 '22 00:09

Fionnuala