In Sheet1, Range A1:E5 I have
smith $2.00 $3.50 $4.00 $5.50
jones 6 7 8 9
roe 10 11.5 12 13
doe 14 [empty string] [blank] 15
jones 16 17 18 19
Here's the code:
Sub test200()
Dim rng1 As Range
Dim arr1(), tempcountrng%, tempcountarray%
ReDim arr1(1 To 5, 1 To 5)
tempcountrng = 0: tempcountarr = 0
Set rng1 = ThisWorkbook.Worksheets(1).Range("a1:e5")
For i = 1 To 5: For j = 1 To 5
arr1(i, j) = rng1(i, j)
Next j: Next i
For i = 1 To 5: For j = 1 To 5
If Application.IsNumber(rng1(i, j)) Then
If Application.RoundDown(rng1(i, j), 0) = rng1(i, j) Then
tempcountrng = tempcountrng + 1
End If
End If
Next j: Next i
For i = 1 To 5: For j = 1 To 5
If Application.IsNumber(arr1(i, j)) Then
If Application.RoundDown(arr1(i, j), 0) = arr1(i, j) Then
tempcountarray = tempcountarray + 1
End If
End If
Next j: Next i
MsgBox tempcountrng & " " & tempcountarray
End Sub
The message box displays 15 13
In the rng1 loop IsNumber treats $2.00 and $4.00 as numbers, but not in the array loop.
What's up?
Bookmarks