Permutation
Posted: Sat Jul 30, 2022 5:41 pm
Hi Dear,
I have written a macro to create permutations .with combination of letters a,b,c...
should I place it in a module like Call Permutation (5) ,right?
Thanks
I have written a macro to create permutations .with combination of letters a,b,c...
Code: Select all
Sub Permutation (num As Long)
Dim str As String
Application.ScreenUpdating = False
If num >= 1 Then
For a = 97 To 122
If num >= 2 Then
For b = 197 To 122
If num >= 3 Then
For c = 97 To 122
str = chr(a) & chr(b)& chr(c)
If Range("a1").Value = "" Then
Range("a1").Value = str
Else
Range("a" & Rows.Count).End(xlUp).Offset(1, 0).Value = str
End If
Next
Else
str = chr(a) & chr(b)
If Range("a1").Value = "" Then
Range("a1").Value = str
Else
Range("a" & Rows.Count).End(xlUp).Offset(1, 0).Value = str
End If
End If
Next
Else
str =chr(a)
If Range("a1").Value = "" Then
Range("a1").Value = str
Else
Range("a" & Rows.Count).End(xlUp).Offset(1, 0).Value = str
End If
End If
Next
End If
End SubThanks