|
发表于 2021-7-31 16:29
|
显示全部楼层
本楼为最佳答案
Sub demo()
Set list1 = CreateObject("System.Collections.ArrayList")
Set d = CreateObject("Scripting.Dictionary")
Sheets(3).UsedRange.ClearContents
a = Sheets(1).UsedRange
b = Sheets(2).UsedRange
For i = 1 To UBound(a)
For k = 1 To UBound(a, 2)
Key = a(i, k): If Key = 0 Then Exit For
If Not list1.contains(Key) Then list1.Add Key
Next
For j = 1 To UBound(b)
Set list2 = list1.Clone
For k = 1 To UBound(b, 2)
Key = b(j, k): If Key = 0 Then Exit For
If Not list2.contains(Key) Then list2.Add Key
Next
list2.Sort
r = r + 1
Sheets(3).Cells(r, 1).Resize(1, list2.Count) = list2.ToArray
Next
list1.Clear
Next
Sheets(4).UsedRange.Offset(1, 0).ClearContents
ay = Sheets(4).[ay1]
r = 1
With Sheets(3)
For i = 1 To .[a1].End(4).Row
c = .Cells(i, 1).End(2).Column
If c > ay Then GoTo 1
Set Rng = Range(.Cells(i, 1), .Cells(i, c))
Key = Join(Application.Transpose(Application.Transpose(Rng)))
If Not d.exists(Key) Then
d(Key) = 1
r = r + 1
Sheets(4).Cells(r, 1).Resize(1, c).Value = Rng.Value
End If
1:
Next
End With
End Sub
祝順心,南無阿彌陀佛!
|
评分
-
查看全部评分
|