Checking the type of data in an array

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
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
 
"Brendan Reynolds" <brenreyn at indigo dot ie> wrote in message
'put your oode to insert into table here
<snip>

.... or code, even! :-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Type Mismatch 4
array data type in table? 1
Arrays and Types 2
vba array logic 3
joining on mis-matched data type 5
Data Type Mismatch 10
Wrong Data Type 4
Append query and Type Mismatch 5

Back
Top