|
方法比较笨,效率不是很高的- Private vChr As Variant, vResult As Variant, nResult As Double
- Sub 递归组合()
- ReDim vResult(1 To 1)
- vChr = Split("A,B,C,D", ",")
- GetStr
- [A1].Resize(nResult) = Application.WorksheetFunction.Transpose(vResult)
- End Sub
- Private Function GetStr(Optional ByVal sStr As String) As String
- Dim nI As Integer
- For nI = LBound(vChr) To UBound(vChr)
- If Not sStr Like "*" & vChr(nI) & "*" Then
- If Len(sStr) = UBound(vChr) Then
- nResult = nResult + 1
- ReDim Preserve vResult(1 To nResult)
- vResult(nResult) = sStr & vChr(nI)
- Exit Function
- Else
- GetStr sStr & vChr(nI)
- End If
- End If
- Next
- End Function
复制代码 |
|