ExcelEveryday1
New Member
- Joined
- Jan 7, 2016
- Messages
- 20
I'm having trouble nesting loops!
How do I nest an "if statement" into a "for to" statement? Can anyone point me to a good place to check my nesting loops?
I'm essentially trying to populate a master list of numbers (z,1) by using matching criteria between two other lists. If two cells of others lists are equal to each other, it returns a certain value to the master(in the example, 5). If there is no match, than it moves to the next row, eventually next column, and eventually a down a row on the master list if there is no match in the other list.
Dim z As Long
Dim y As Long
Dim x As Long
For z = FirstRow To LastRow
For y = 1 To 4
For x = 11 To 40
If ... then
result
Else:
End If
Next x
If x = 40 Then
Next y
If y = 4 Then
Next Z
How do I nest an "if statement" into a "for to" statement? Can anyone point me to a good place to check my nesting loops?
I'm essentially trying to populate a master list of numbers (z,1) by using matching criteria between two other lists. If two cells of others lists are equal to each other, it returns a certain value to the master(in the example, 5). If there is no match, than it moves to the next row, eventually next column, and eventually a down a row on the master list if there is no match in the other list.
Dim z As Long
Dim y As Long
Dim x As Long
For z = FirstRow To LastRow
For y = 1 To 4
For x = 11 To 40
If ... then
result
Else:
End If
Next x
If x = 40 Then
Next y
If y = 4 Then
Next Z