snt work on this
How to generate or list all possible permutations in Excel?
For example, I have three characters XYZ, now, I want to list all possible permutations based on these three characters to get six different results as this: XYZ, XZY, YXZ, YZX, ZXY and ZYX. In Excel, how could you quickly generate or list all permutations based on different number of characters?
The following VBA code may help you to list all permutations based on your specific number of letters please do as follows:
1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.
2. Click Insert > Module, and paste the following code in the Module Window.
VBA code: List all possible permutations in excel
Sub GetString() 'Updateby Extendoffice 20160606 Dim xStr As String Dim FRow As Long Dim xScreen As Boolean xScreen = Application.ScreenUpdating Application.ScreenUpdating = False xStr = Application.InputBox("Enter text to permute:", "Kutools for Excel", , , , , , 2) If Len(xStr) < 2 Then Exit Sub If Len(xStr) >= 8 Then MsgBox "Too many permutations!", vbInformation, "Kutools for Excel" Exit Sub Else ActiveSheet.Columns(1).Clear FRow = 1 Call GetPermutation("", xStr, FRow) End If Application.ScreenUpdating = xScreen End Sub Sub GetPermutation(Str1 As String, Str2 As String, ByRef xRow As Long) Dim i As Integer, xLen As Integer xLen = Len(Str2) If xLen < 2 Then Range("A" & xRow) = Str1 & Str2 xRow = xRow + 1 Else For i = 1 To xLen Call GetPermutation(Str1 + Mid(Str2, i, 1), Left(Str2, i - 1) + Right(Str2, xLen - i), xRow) Next End If End Sub
3. Then press F5 key to run this code, and a prompt box is popped out to remind you enter the characters that you want to list all permutations, see screenshot:
4. After entering the characters, and then click OK button, all the possible permutations are displayed in column A of active worksheet. See screenshot:
Note: If the entered character length is equal or greater than 8 characters, this code will not work because there are too many permutations.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
To post as a guest, your comment is unpublished.· 1 months agowho can send me a list of 10 diferent items permutatted by 2 outcomes. this code doe
snt work on this
To post as a guest, your comment is unpublished.· 3 months agopeki bunu listeleyecek bir program uygulama yok mu?basit sıradan bir hesaplamadan daha fazlasına ihtiyacı olan ne yapacak?
To post as a guest, your comment is unpublished.· 4 months agothis code will not work because there are two many permutations
this code will not work because there are too many permutations
To post as a guest, your comment is unpublished.· 1 years agoHello everyone. I need help on this. I have two alphabets to be permutated in 20 rows. But am not getting it right. Anyone who could help me out should send the permutation to my email. email@example.com.
1.a b b a
2.a a b b
3.a a b b
4.a a b b
5.a a b b
6.a a b b
7.a a b b
8.a a b b
9.a a b b
10.a a b b
11.a a b b
12.a a b b
13.a a b b
14.a a b b
15.a a b b
16.a a b b
17.a a b b
18.a a b b
19.a a b b
20.a a b b
To post as a guest, your comment is unpublished.
To post as a guest, your comment is unpublished.· 1 years ago@Supraja...
in the first sub clear all cells... not just the first row
Sub GetPermutation(Str1 As String, Str2 As String, ByRef xRow As Long)
Dim i As Integer, xLen As Integer
xLen = Len(Str2)
If xLen < 2 Then
'move to the next column when you get to 100
Cells(((xRow - 1) Mod 100) + 1, 1 + Int(xRow / 100)) = Str1 & Str2
xRow = xRow + 1
For i = 1 To xLen
Call GetPermutation(Str1 + Mid(Str2, i, 1), Left(Str2, i - 1) + Right(Str2, xLen - i), xRow)
To post as a guest, your comment is unpublished.· 1 years agoHello,
Im trying to get a permutation for 82 characters, the code provided works, but, since the columns are only 1048576, I want to move the next output in B,C,D..... Can any of you help me on this regard
To post as a guest, your comment is unpublished.· 2 years agoHello,
Im doing a small project using permutation and combination rules. I need your support on this please.
Scenario: I have 13 digit alpha numeric data (00SHGO8BJIDG0) I want a coding to interchange S to 5, I to 1 and O to 0 and vise versa.
The project is that if I have the correct 13 digit data I will receive a 3 digit pass code.
(eg) 00SHG08BJ1DG0 - 500 is the pass code but because of wrong typo that is instead of 1 it was I and 0 it was O there is a wrong info.
can you please help me.