I have been using what's in Code Sample 2 (to be unveiled after Code Sample 1). Then while trying to figure out how stuff works, I wrote a tester Sub:
Code Sample 1:
Sub Ztest()
Dim inty As Integer
inty = Cells(1, 1)
MsgBox inty
If IsNumeric(inty) Then
MsgBox "Numeric"
End If
End Sub
The above code gives me an error if I have a non numeric in A1. This is what I expect. Then why does the below code (which I wrote when i was naive...a few months ago) NOT give me the same error? You can see I even added a little MsgBox to talk to me AFTER it processes a non numeric. I have thrown random strings (asdfasd) at the following code without messing it up.
In Sample 1, I can change it to Variant, for example, and it works fine. But why does Sample 2 seem to be treating it as Variant? What's VBA doing that I'm not seeing?
Code Sample 2:
Dim current, bogey, status As Integer
For i = TR To BR
If Cells(i, RowCodeCol) > 0 And Cells(i, RowCodeCol) < 11 Then
'reinitialize bogey, status to 0 for each row
bogey = 0
status = 0
For j = 1 To iCount
current = Cells(i, PNColumnArray(j))
If Not IsNumeric(current) Then
MsgBox current
Exit Sub
End If
Thanks
Bookmarks