Actually
=combin(4,4) reveals the obvious. There is only one unique combination of
the letters A B C D
Now if we are talking permutations as she appears to describe, then
see John Walkenbach's site for code to generate the 24 possible
permutations.
=PERMUT(4,4)
http://j-walk.com/ss/excel/tips/tip46.htm
Your code repeats characters - AAAA would be a possible result - which may
or may not be what she wants, but nothing with repeating characters was
shown in the example.
--
Regards,
"BrianB " wrote in message
...
You need to know the number of items in advance. Using your example
there are 256 possibilities.
'------------------------------------------------------------
Sub TEST()
Dim MyRange As Range
Dim ToRow As Long
'------------------
Set MyRange = Selection '(eg.4 cells A1:A4)
ToRow = 1
For n1 = 1 To 4
For n2 = 1 To 4
For n3 = 1 To 4
For n4 = 1 To 4
ActiveSheet.Cells(ToRow, 2).Value =
MyRange.Cells(n1, 1).Value
ActiveSheet.Cells(ToRow, 3).Value =
MyRange.Cells(n2, 1).Value
ActiveSheet.Cells(ToRow, 4).Value =
MyRange.Cells(n3, 1).Value
ActiveSheet.Cells(ToRow, 5).Value =
MyRange.Cells(n4, 1).Value
ToRow = ToRow + 1
Next
Next
Next
Next
End Sub
'----------------------------------------------
---
Message posted from http://www.ExcelForum.com/