I'm trying to run a loop on 3 variables, where order doesn't matter.
The code I've tried first is the following, where nx runs through the rows, and limit is the last row of my database:
Do While n3 <= limit
Do While n2 <= limit
Do While n1 <= limit
Call Output
n1 = n1 + 1
Loop
Call Output
n2 = n2 + 1
n1 = n0
Loop
Call Output
n3 = n3 + 1
n2 = n0
n1 = n0
Loop
This allows me to test every possibility, but it does also repeat the same combination several times, which increases the runtime. This will make the code unusable if I plan on testing, let's say, 20 variables.
Any tips on how to optimize this loop?
Thank you.

