lrobbo314
Well-known Member
- Joined
- Jul 14, 2008
- Messages
- 3,963
- Office Version
- 365
- Platform
- Windows
I have the data below. The data is in E1:J15.
I need to get all possible combinations of the names in the table.
But, the number of names from each column must correspond with the numbers in row 1.
So the first result would be
Andy, Doug, Eddie, Allen, Calvin, Eric, Greg, Graham, Bill
Then it would cycle through all the P6 entries. So the next one would be
Andy, Doug, Eddie, Allen, Calvin, Eric, Greg, Graham, Miguel
then
Andy, Doug, Eddie, Allen, Calvin, Eric, Greg, Graham, Tristan and so on until all possible combinations were listed.
I
[table="width: 500, class: grid"]
[tr]
[td]1[/td]
[td]2[/td]
[td]3[/td]
[td]1[/td]
[td]1[/td]
[td]1[/td]
[/tr]
[tr]
[td]P1[/td]
[td]P2[/td]
[td]P3[/td]
[td]P4[/td]
[td]P5[/td]
[td]P6[/td]
[/tr]
[tr]
[td]Andy[/td]
[td]Doug[/td]
[td]Allen[/td]
[td]Greg[/td]
[td]Graham[/td]
[td]Bill[/td]
[/tr]
[tr]
[td]Tom[/td]
[td]Eddie[/td]
[td]Calvin[/td]
[td]Tyler[/td]
[td]Mason[/td]
[td]Sanchez[/td]
[/tr]
[tr]
[td]Ryan[/td]
[td]Frank[/td]
[td]Eric[/td]
[td]Gary[/td]
[td]Robbie[/td]
[td]Miguel[/td]
[/tr]
[tr]
[td]Ben[/td]
[td]Jeremy[/td]
[td]Randall[/td]
[td]Travis[/td]
[td]Adam[/td]
[td]Tristan[/td]
[/tr]
[tr]
[td]Matthew[/td]
[td]Jonathan[/td]
[td]Vincent[/td]
[td]Austin[/td]
[td]Randy[/td]
[td]Morgan[/td]
[/tr]
[tr]
[td]Johnny[/td]
[td]Mark[/td]
[td]Travis[/td]
[td]Scott[/td]
[td]Dustin[/td]
[td]TJ[/td]
[/tr]
[tr]
[td]Philip[/td]
[td]Matt[/td]
[td]Steve[/td]
[td]Richard[/td]
[td]Dan[/td]
[td]Kyle[/td]
[/tr]
[tr]
[td]Brian[/td]
[td]Shane[/td]
[td]Jordan[/td]
[td]Charles[/td]
[td]Phil[/td]
[td]Mike[/td]
[/tr]
[tr]
[td]Derek[/td]
[td]Thomas[/td]
[td]Rueben[/td]
[td]Jason[/td]
[td]Matt[/td]
[td]Leroy[/td]
[/tr]
[tr]
[td]Sam[/td]
[td][/td]
[td]Willie[/td]
[td][/td]
[td]Andrew[/td]
[td][/td]
[/tr]
[tr]
[td][/td]
[td][/td]
[td]Nate[/td]
[td][/td]
[td]Sebastian[/td]
[td][/td]
[/tr]
[tr]
[td][/td]
[td][/td]
[td][/td]
[td][/td]
[td]Josh[/td]
[td][/td]
[/tr]
[tr]
[td][/td]
[td][/td]
[td][/td]
[td][/td]
[td]Caleb[/td]
[td][/td]
[/tr]
[/table]
I have the following recursive code from an old project
But it deals with just 1 single dimension array.
Honestly I am not very familiar with recursive programming and adjusting the code for these new constraints is a bit above my head.
Any help would be greatly appreciated. Thanks.
I need to get all possible combinations of the names in the table.
But, the number of names from each column must correspond with the numbers in row 1.
So the first result would be
Andy, Doug, Eddie, Allen, Calvin, Eric, Greg, Graham, Bill
Then it would cycle through all the P6 entries. So the next one would be
Andy, Doug, Eddie, Allen, Calvin, Eric, Greg, Graham, Miguel
then
Andy, Doug, Eddie, Allen, Calvin, Eric, Greg, Graham, Tristan and so on until all possible combinations were listed.
I
[table="width: 500, class: grid"]
[tr]
[td]1[/td]
[td]2[/td]
[td]3[/td]
[td]1[/td]
[td]1[/td]
[td]1[/td]
[/tr]
[tr]
[td]P1[/td]
[td]P2[/td]
[td]P3[/td]
[td]P4[/td]
[td]P5[/td]
[td]P6[/td]
[/tr]
[tr]
[td]Andy[/td]
[td]Doug[/td]
[td]Allen[/td]
[td]Greg[/td]
[td]Graham[/td]
[td]Bill[/td]
[/tr]
[tr]
[td]Tom[/td]
[td]Eddie[/td]
[td]Calvin[/td]
[td]Tyler[/td]
[td]Mason[/td]
[td]Sanchez[/td]
[/tr]
[tr]
[td]Ryan[/td]
[td]Frank[/td]
[td]Eric[/td]
[td]Gary[/td]
[td]Robbie[/td]
[td]Miguel[/td]
[/tr]
[tr]
[td]Ben[/td]
[td]Jeremy[/td]
[td]Randall[/td]
[td]Travis[/td]
[td]Adam[/td]
[td]Tristan[/td]
[/tr]
[tr]
[td]Matthew[/td]
[td]Jonathan[/td]
[td]Vincent[/td]
[td]Austin[/td]
[td]Randy[/td]
[td]Morgan[/td]
[/tr]
[tr]
[td]Johnny[/td]
[td]Mark[/td]
[td]Travis[/td]
[td]Scott[/td]
[td]Dustin[/td]
[td]TJ[/td]
[/tr]
[tr]
[td]Philip[/td]
[td]Matt[/td]
[td]Steve[/td]
[td]Richard[/td]
[td]Dan[/td]
[td]Kyle[/td]
[/tr]
[tr]
[td]Brian[/td]
[td]Shane[/td]
[td]Jordan[/td]
[td]Charles[/td]
[td]Phil[/td]
[td]Mike[/td]
[/tr]
[tr]
[td]Derek[/td]
[td]Thomas[/td]
[td]Rueben[/td]
[td]Jason[/td]
[td]Matt[/td]
[td]Leroy[/td]
[/tr]
[tr]
[td]Sam[/td]
[td][/td]
[td]Willie[/td]
[td][/td]
[td]Andrew[/td]
[td][/td]
[/tr]
[tr]
[td][/td]
[td][/td]
[td]Nate[/td]
[td][/td]
[td]Sebastian[/td]
[td][/td]
[/tr]
[tr]
[td][/td]
[td][/td]
[td][/td]
[td][/td]
[td]Josh[/td]
[td][/td]
[/tr]
[tr]
[td][/td]
[td][/td]
[td][/td]
[td][/td]
[td]Caleb[/td]
[td][/td]
[/tr]
[/table]
I have the following recursive code from an old project
Code:
Sub Combo()
Dim vArray() As Variant, vResult() As Variant
Dim lRow As Long
Dim r As Range
Set r = Range("A1:A3")
For i = 0 To r.Rows.Count - 1
ReDim Preserve vArray(0 To i)
vArray(i) = r(i + 1)
Next
vResult = vArray
perm1 vArray, vResult, 0, lRow
End Sub
Sub perm1(vArray As Variant, vResult As Variant, lInd As Long, lRow As Long)
Dim j As Long
Dim res As Double
For j = 0 To UBound(vArray)
vResult(lInd) = vArray(j)
If lInd = UBound(vArray) Then
lRow = lRow + 1
Range("J" & lRow).Resize(1, UBound(vArray) - LBound(vArray) + 1).Value = vResult
Else
perm1 vArray, vResult, lInd + 1, lRow
End If
Next j
End Sub
But it deals with just 1 single dimension array.
Honestly I am not very familiar with recursive programming and adjusting the code for these new constraints is a bit above my head.
Any help would be greatly appreciated. Thanks.