View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
[email protected] its.a.scign@googlemail.com is offline
external usenet poster
 
Posts: 1
Default use different string variables in FOR loop

A For loop can only use a number for the count. However you can set up
an array with the strings in it, then use the loop variable to count
through the elements of the array.

<Code

Dim words(4) As String
words(0) = "red"
words(1) = "green"
words(2) = "blue"
words(3) = "orange"

' This will print each of those words in order
For i = 0 To UBound(words) - 1
Debug.Print words(i)
Next

</Code

As long as you can get the words you want to cycle through into an
array, you can count through them in a loop this way.

Does that help?



On Sep 20, 5:14*pm, John Keith wrote:
I would like to create a FOR loop that uses many different string
values as the loop variable, maybe 20-30 different values.

What kind of structure is required to loop through a list of string
varibles like this:

red
green
blue
orange
and so on....

Thanks

John Keith