Sub Combinations()
Const MYSET As String = "A,B,C,D,E,F" 'any values delimited by ","
Dim aElems() As String, aNibs(7) As Byte, i As Integer, j As Integer, nElems As Integer, s As String
aElems() = Split(MYSET, ",")
nElems = UBound(aElems)
If nElems > 7 Then MsgBox "Too many elements: " & nElems + 1: Exit Sub
aNibs(0) = 1: aNibs(1) = 2: aNibs(2) = 4: aNibs(3) = 8: aNibs(4) = 16: aNibs(5) = 32: aNibs(6) = 64: aNibs(7) = 128
For i = 1 To 2 ^ (nElems + 1) - 1
s = ""
For j = 0 To nElems
If i And aNibs(j) Then s = s & aElems(j)
Next
Debug.Print s
Next
End Sub
|