Webb_GM_2010
New Member
- Joined
- Apr 12, 2010
- Messages
- 6
Hello All,
I have a simple VBA code which generates all possible combinations from a list (A, B, C). The code returns all 27 combinations from AAA to CCC. However, I would like to generate ONLY the unique values (so values without repeating the same item). The list of values I want would therefore be only 6.
A B C
A C B
B A C
B C A
C A B
C B A
The code I am currently using is:
Please can you help incorporate this into the code or write a completely new one.
Thanks for your help!
I have a simple VBA code which generates all possible combinations from a list (A, B, C). The code returns all 27 combinations from AAA to CCC. However, I would like to generate ONLY the unique values (so values without repeating the same item). The list of values I want would therefore be only 6.
A B C
A C B
B A C
B C A
C A B
C B A
The code I am currently using is:
Code:
Private Sub Test_Click()
Dim MyArray(2)
MyArray(0) = "A"
MyArray(1) = "B"
MyArray(2) = "C"
r = 2
col = 2
For a = 0 To 2
For b = 0 To 2
For c = 0 To 2
Cells(r, col) = MyArray(a) & MyArray(b) & MyArray(c)
r = r + 1
Next c
Next b
Next a
End Sub
Please can you help incorporate this into the code or write a completely new one.
Thanks for your help!