1. Given a list of n characters, is it possible to create code which will produce for further processing:
• All permutations taken 2 at a time; then
• All permutations taken 3 at a time; then
• All permutations taken 4 at a time; then
• All permutations taken 5 at a time; etc up to
• All permutations taken n at a time
I have been pondering this abstract situation for some time without any breakthrough. Given a fixed value for n I believe it would not present a great challenge to create code specific to the task. My problem is in the development of a concept to handle n being passed as an argument.

2. I'm kinda math challenged this morning (and when its' this cold!).
Can you give me an example of what you are trying to do?

3. I echo WebGenii's question and wonder if =FACT() is of use in your quest.

4. Originally Posted by WebGenii
Can you give me an example of what you are trying to do?
Let us assume that the project we are trying to develop is passed the five character collection: A; S; D; F; and G. The project would create and pass as arguments for further processing, the data in columns A of the attached workbook.

• It would first pass each of the 20 data items in column A individually in no particular order for processing;
• It would then pass each of the 60 data items in column B individually in no particular order for processing;
• It would then pass each of the 120 data items in column C individually in no particular order for processing;
• It would then pass each of the 120 data items in column D individually in no particular order for processing;

6. Originally Posted by WebGenii
Here's the same file as a text file in csv format.

7. Hi Don

Here is my starter for 10

It is not complete but hopefully you can finish the number of loops required and possibly using the Mid function instead of the Left function (off to bed soon)

Code:
```Dim CurrentRow
Sub GetString()
Dim InString As String
Dim NewString As String
InString = InputBox("Enter text:")

ActiveSheet.Columns(1).Clear
CurrentRow = 1
If Len(InString) < 1 Then Exit Sub
For i = 1 To Len(InString)
NewString = Left(InString, i)
If Len(InString) >= 8 Then
MsgBox "Too many permutations!"
Exit Sub
Else

Call Permute("", NewString)
End If
Next i
End Sub

Sub Permute(x As String, y As String)
Dim i As Integer, j As Integer
j = Len(y)
If j < 2 Then
Cells(CurrentRow, 1) = x & y
CurrentRow = CurrentRow + 1
Else
For i = 1 To j
Call Permute(x + Mid(y, i, 1), _
Left(y, i - 1) + Right(y, j - i))
Next
End If
End Sub```

8. There is actually a PERMUT function

9. Originally Posted by WebGenii
There is actually a PERMUT function
The PERMUT function returns the number of permutations which can be found in a given collection, taken n items at a time. I am not after the quantity, but the actual permutations (arrangements), themselves.

10. Originally Posted by Don Wells
The PERMUT function returns the number of permutations which can be found in a given collection, taken n items at a time. I am not after the quantity, but the actual permutations (arrangements), themselves.
Hi Don

This is way, way above my head as you probably already know, in an attempt to repay your previous generous help on the board and I have been doing some Googling and this one seems promising as it mentioned the variable 'n' as you have

http://www.ehow.com/how_4466533_calc...mutations.html

Hope that is of some use

11. Originally Posted by Don Wells
The PERMUT function returns the number of permutations which can be found in a given collection, taken n items at a time. I am not after the quantity, but the actual permutations (arrangements), themselves.
I understand
I'm trying to do a non-VBA version, I can see why using VBA might be preferable.

12. Apologies to all. I misstated the original requirements.

Where permutations do not allow repetition of a collection item, my requirement does. Examples follow:

The permutations of A; B; and C taken 2 at a time are: AB; AC; BA; BC; CA; and CB

My requirement of A; B; and C taken 2 at a time are the permutations plus AA; BB; and CC:

13. well that just made things a lot easier!

14. Originally Posted by Don Wells
Apologies to all. I misstated the original requirements.

Where permutations do not allow repetition of a collection item, my requirement does. Examples follow:

The permutations of A; B; and C taken 2 at a time are: AB; AC; BA; BC; CA; and CB

My requirement of A; B; and C taken 2 at a time are the permutations plus AA; BB; and CC:
I assume my offering of the code is not to your liking?

15. Don,
I started a post on 11/4/2009 very similar to this. I am sorry, but I don't know how to post it. It is entitled "Combinations".
Good Luck

Page 1 of 2 12 Last

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•