finding all possible arrangements of a series

tbird

Board Regular
Joined
Oct 21, 2002
Messages
184
Is there a combination of functions that could be used to reorder a series of letters residing in cell A1 to list all the possible arrangements of those letters? For example: If A1 contains the text: "ABCD"; I would want to see all the possible arrangements of those four letters listed in column B starting at B1 with "ACDB" or "DCBA" (or any other), then in B2: "ADCB", etc.

Any ideas?
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Yes, but it would be really bulky and probably more conducive to doing by code. How many letters would be in each cell to be rearranged? If it's 4, that's not so hard, but if you're thinking about 20 or 50 or more...
 
Upvote 0
Hi tbird

Write the word in A1

Try:

Code:
Sub PermutWords()
Dim lrow As Long
 
PermutWords1 Range("A1"), "", lrow
End Sub
 
Function PermutWords1(ByVal s As String, ByVal sPermut As String, ByRef lrow As Long)
Dim l As Long
 
If Len(s) = 1 Then
    lrow = lrow + 1
    Range("B" & lrow) = sPermut & s
Else
    For l = 1 To Len(s)
        PermutWords1 Replace(s, Mid(s, l, 1), ""), sPermut & Mid(s, l, 1), lrow
    Next l
End If
End Function
 
Upvote 0

Forum statistics

Threads
1,215,372
Messages
6,124,535
Members
449,169
Latest member
mm424

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top