I have a permutation problem requiring many nested loops that are structurally identical.

E.g.

I work with the range A1:C50

The code will write values to column A and B. Column C contains a formula evaluating A and B.

The code starts by assigning an iteration value from 1-20 to column A / row 1, then an iteration value from 1-4 to column B / row 1.

If C = TRUE then the code goes on to the next row. If all rows 1-50 in column C = TRUE than the problem is solved.

Whenever C = FALSE, column B iterations will first be exhausted, then column A iterations, before moving back to the previous row and continuing the iteration there.

I know how to do this by writing each loop separately, i.e.

For i_A_1 = 1 to 20

If Cells(1,3) = FALSE then

GoTo Line_NextIteration_1

End if

etc.

For i_B_1 = 1 to 4

etc.

Line_NextIteration_50:

Next i_B_50

Next i_A_50

etc.

Line_NextIteration_1

Next i_B_1

Next i_A_1

However, I wonder if there's away to avoid all this code since each loop is structurally identical and use variable iterations, e.g. from x = 1 to 50, i_A_x = "i_A_" & x. However, I'm not sure how I would accomplish the descending Next statements with this approach? Thanks.