四个字符串,怎样用excel或其他工具列出所有排列组合
列出aabb1122、aabb2211、1122aabb……共24种组合
求方法,不是求结果哦 展开
用VBA求,下面是代码:
Private Sub CommandButton1_Click()
Dim i, j, k, l, m As Integer
Dim strArr(1 To 4), strS As String
strArr(1) = "aa"
strArr(2) = "bb"
strArr(3) = "11"
strArr(4) = "22"
m = 1
For i = 1 To 4
For j = 1 To 4
For k = 1 To 4
For l = 1 To 4
If i <> j And i <> k And i <> l And j <> k And k <> l And j <> l Then
strS = strArr(i) & strArr(j) & strArr(k) & strArr(l)
Cells(m, 1) = strS
m = m + 1
End If
Next l
Next k
Next j
Next i
End Sub