Sub 按钮2_Click()
arr = Sheets("原始数据").[a1].CurrentRegion
x = UBound(arr) ^ UBound(arr, 2)
ReDim brr(1 To x, 1 To UBound(arr, 2))
Set d = CreateObject("scripting.dictionary")
Set dd = CreateObject("scripting.dictionary")
r = 0
dg arr, brr, r, 1, "", d, dd
[h1].Resize(r, UBound(brr, 2)) = brr
End Sub
Sub dg(arr, brr, r, c, str1, d, dd)
For j = 1 To UBound(arr)
If Len(arr(j, c)) > 0 Then
If c = UBound(arr, 2) Then
str2 = str1 & "," & arr(j, c)
crr = Split(str1 & "," & arr(j, c), ",")
dd.RemoveAll
For k = 1 To UBound(crr)
dd(Val(crr(k))) = ""
Next k
str2 = ""
For k = 1 To dd.Count
str2 = str2 & "," & WorksheetFunction.Small(dd.keys, k)
Next k
If Not d.exists(str2) Then
d(str2) = ""
r = r + 1
For k = 0 To dd.Count - 1
brr(r, k + 1) = dd.keys()(k)
Next k
End If
Else
Call dg(arr, brr, r, c + 1, str1 & "," & arr(j, c), d, dd)
End If
End If
Next j
End Sub
|