Determining if a cell value is an integer

Closed
mtbtweety Posts 1 Registration date Tuesday March 3, 2009 Status Member Last seen March 4, 2009 - Mar 4, 2009 at 01:08 PM
 WutUp WutUp - Mar 4, 2009 at 04:15 PM
Hello,
I'm getting type mismatch errors in a Macro, and am trying to resolve it by checking to see if the cell contains an integer, but can't figure out how to do that.

Current line is
If Selection.Cells(i) > 0 Then l = l + 1

I'd like ti to be more like
If (Selection.Cells(i) > 0 AND Selection.Cells(i).type=Integer) Then l = l + 1

but that clearly doesn't work. What's the right language for this?

1 response

Maybe you can try an information function with a data type function. Something like.......

If IsNumeric(Val(Selection.Cells(i))) Then
l = l + 1
2