|
本帖最后由 ykcbf1100 于 2024-4-8 09:57 编辑
代码更新一下。。。
- Sub ykcbf() '//2024.4.8
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set d = CreateObject("Scripting.Dictionary")
- Set d1 = CreateObject("Scripting.Dictionary")
- Dim tm: tm = Timer
- With Sheets("Sheet1")
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .[a1].Resize(r, 24)
- For i = 1 To UBound(arr)
- s = arr(i, 13)
- d1(s) = ""
- Next
- For Each k In d1.keys
- n = n + 1
- For i = 1 To UBound(arr)
- s = arr(i, 13)
- If s = k Then
- d(n) = i
- Exit For
- End If
- Next
- Next
- End With
- ReDim brr(1 To 100000, 1 To UBound(arr, 2))
- On Error Resume Next
- m = 0
- For k = 1 To d.Count
- r1 = d(k)
- If k = d.Count Then r2 = r Else r2 = d(k + 1) - 1
- For i = r1 To r2
- For x = i + 1 To r2
- m = m + 3
- For j = 1 To UBound(arr, 2)
- brr(m - 2, j) = arr(i, j)
- brr(m - 1, j) = arr(x, j)
- Next j
- Next x
- Next i
- Next
- With Sheets("Sheet2")
- .UsedRange = ""
- .[a1].Resize(m, 24) = brr
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "共用时:" & Format(Timer - tm) & "秒!"
- End Sub
复制代码
|
|