用宏比较简单,按Alt+F11,在菜单选"插入"\"宏"
Sub Perm()
TextToPerm = InputBox("输入需组合字符:")
Tlen = Len(TextToPerm)
PermNo = WorksheetFunction.Permut(Tlen, Tlen)
For i = 0 To PermNo - 1
Result = ""
Remain = TextToPerm
For j = Tlen To 1 Step -1
Product = 1
If j > 2 Then
For x = 1 To j - 1
Product = Product * x
Next x
End If
Digit = Mid(Remain, 1 + Int(i / Product) Mod j, 1)
Remain = WorksheetFunction.Substitute(Remain, Digit, "")
Result = Result & Digit
Next j
ActiveCell.NumberFormat = "@"
ActiveCell = Result
ActiveCell.Offset(1, 0).Select
Next i
End Sub
回到工作簿,按Alt+F8执行Perm
这个宏会在执行后在所选单元格往下把可能项列出。
温馨提示:答案为网友推荐,仅供参考