Ralajer
Active Member
- Joined
- Jul 24, 2008
- Messages
- 416
Hello all,
I know that this must have been answered before but I can't find the phrasing and syntax to narrow down the search results.
Is there a set systematic order a for each loop will loop through a range?
I've tested it with the following code
It loops through the columns first A1, B1, C1, D1 then row 2. Is the loop order something that is fixed and can be count on when coding?
Thanks in advance
I know that this must have been answered before but I can't find the phrasing and syntax to narrow down the search results.
Is there a set systematic order a for each loop will loop through a range?
I've tested it with the following code
Code:
Sub testFEL()
Dim myRange As Range, cell As Range
Dim i As Integer
Set myRange = Range("A1:D3")
i = 1
For Each cell In myRange
cell.Value = i
i = i + 1
Next cell
End Sub
It loops through the columns first A1, B1, C1, D1 then row 2. Is the loop order something that is fixed and can be count on when coding?
Thanks in advance