Checking the type of data in an array

  • Thread starter Maury Markowitz
  • Start date
M

Maury Markowitz

I have an array returned by an external ActiveX component. Some of the data
is numeric, some isn't. I would like to take all the numeric values and put
them into a table.

I thought this would be easy, simply assign them and let ON ERROR skip over
those that don't work. For some reason this does not work, the ON ERROR is
ignored and the type mismatch causes a drop into the debugger. Sigh.

Ok, what do I do?
 
B

Brendan Reynolds

Public Sub TestArray()

Dim varArray As Variant
Dim varItem As Variant

varArray = Array(1, "two", 3, "four", 5, "six")
For Each varItem In varArray
If IsNumeric(varItem) Then

'put your oode to insert into table here
Debug.Print varItem

End If
Next varItem

End Sub
 
Top