Do Loop with list of text values

  • Thread starter Thread starter Chuck Frank
  • Start date Start date
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.
 
Dim myArray() As Variant
Dim I As Integer
myArray = Array("AL", "AK", "AR")
For I = 0 To UBound(myArray())
strState = myArray(I)
Next
..
 
Back
Top