Skip to main content
Support is Online
We're back! We are here to assist you. Please be patient, we will respond to your tickets shortly.
Official support hours
Monday To Friday
From 09:00 To 17:30
  Wednesday, 29 December 2021
  5 Replies
  7.5K Visits
0
Votes
Undo
Este Código VBA: Liste todas as permutações possíveis no Excel, preciso de uma modificão nele na forma de entrada, que está em 'MsgBox' e eu preciso que seja em uma seleção de 1 coluna, e a quantidade de linha dentro das linhas selecionadas, e possivel fazer a modificação no código.
Sai 'MsgBox "Too many permutations!", vbInformation, "Kutools for Excel"' Que é somente  digitável e não por seleção
Entra 'seleção de 1 coluna/linhas.
exemplo
linhas selecionadas 12345678 permutar 5 das 8 continuando como esta no codigo.
começa 12345
'termina em 87654.

'Sub
GetString()

'Updateby Extendoffice

    
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
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
2 years ago
·
#2419
0
Votes
Undo
Hi Angeliton,

I saw your code, but I don't quite understand you. Can you speak English?

Amanda
2 years ago
·
#2420
0
Votes
Undo
This VBA Code: List all possible permutations in Excel, I need a modification in it in the form of input, which is in 'MsgBox' and I need it to be in a selection of 1 column, and the amount of row within the selected lines, and possible to make the modification in the code.
reply reply
Exits 'MsgBox', "Too many permutations!", vbInformation, "Kutools for Excel"' Which is only digitized and not by selection
Enter '1 column/rows selection.
example
rows of a selected column 12345678 5 of the 8 continuing like this in code.
starts 12345
ends in 87654. observation data entry by selection in the column
2 years ago
·
#2421
0
Votes
Undo
Hi Angeliton,

So sorry that I could not fully understand you... Hope you can reorganize the word.

Thanks in advance.
Amanda
2 years ago
·
#2422
0
Votes
Undo
Hi Amanda Lee, this code has input data to be exchanged / possible combinations in MsgBox "Too many permutations!", vbInformation, "Kutools for Excel"
I need input data to be swapped/possible combinations in column selection.
example
column 1
1 line = white
2 line = black
3 Line = blue
4 line = yellow
5 line = green
These lines will swap in all possible combinations, the code already does that so I can't select the permutation lines, because the input is a MsgBox that is typed and not selected.
full code is here : https://www.extendoffice.com/documents/excel/3657-excel-generate-all-permutations.html
,
2 years ago
·
#2423
0
Votes
Undo
Hi Angeliton,

Sorry for the late reply.

Please try the code below: (Note that the code does not process a string with over 8 characters. If you want to make the number bigger, you can change the number 8 of "If Len(xStr) >= 8 Then" in the code to bigger numbers. However, the bigger the number is, the slower the program would be.)

Sub GetString()
'Updateby Extendoffice
Dim xStr As String
Dim FRow As Long
Dim xScreen As Boolean
Dim Rg, xRg As Range
xScreen = Application.ScreenUpdating
Application.ScreenUpdating = False
Set xRg = Application.InputBox("Enter text to permute:", "Kutools for Excel", , , , , , 8)
xStr = ""
For Each Rg In xRg
xStr = xStr + Rg.Text
Next
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


Hope this works for you.

Amanda
  • Page :
  • 1
There are no replies made for this post yet.