Randomized Paired Comparison Array
I would generate an array of combinations, then randomly select from that
array, removing each pair that I process.
For generating pairs, you could modify this code from John Warren to return
an array of pairs of indexes into your array.
'
' Posted by John Warren, Excel-L
' March 27, 2001
Sub Combinations()
Dim n As Integer, m As Integer
numcomb = 0
n = InputBox("Number of items?", "Combinations")
m = InputBox("Taken how many at a time?", "Combinations")
Comb2 n, m, 1, "'"
End Sub
'Generate combinations of integers k..n taken m at a time, recursively
Sub Comb2(ByVal n As Integer, ByVal m As Integer, _
ByVal k As Integer, ByVal s As String)
If m n - k + 1 Then Exit Sub
If m = 0 Then
ActiveCell = s
ActiveCell.Offset(1, 0).Select
Exit Sub
End If
Comb2 n, m - 1, k + 1, s & k & " "
Comb2 n, m, k + 1, s
End Sub
--
Regards,
Tom Ogilvy
"John Michl" wrote in message
oups.com...
I'd like to create a process that would allow the user to pair up every
possible combination of two items in an array and make a comparison of
the two (let's just say they pick the one they like better. I assume I
could use nested For-Next loops to do the work something but I'd like
input on three things:
1) Avoid repeating combinations, for instance: Compare A to B and later
B to A
2) Avoid comparisons to self: Compare A to A
3) Randomize comparisons. If using For-Next, it would first compare A
to all other options, then B to all other, then C, etc. How could I
skip around but be sure that All possible combinations are asked but
not repeated?
Thanks for the advice.
- John
|