Do Loop with list of text values

C

Chuck Frank

Hi All,

I would like to write a loop that uses state abbreviations.
I have written a simple procedure to import tables for
each state that is called "ImportTable". The state
abbreviation is stored in the "strState" string variable.
Right now, my code looks like this:

strState = "AL"
ImportTable
strState = "AK"
ImportTable
strState = "AR"
ImportTable

Is there a way I can specify what the variable value is
going to be in a list? Something more like this:

Do list ("AL", "AK", "AR")
ImportTable

I'm not sure how to do the syntax for a list of variable
values.

Thanks.
 
N

none

Dim myArray() As Variant
Dim I As Integer
myArray = Array("AL", "AK", "AR")
For I = 0 To UBound(myArray())
strState = myArray(I)
Next
..
 

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

Top