|
参与一下。。。- Sub ykcbf55() '//2024.1.25
- Dim arr, d
- Application.ScreenUpdating = False
- Set d = CreateObject("Scripting.Dictionary")
- Set d1 = CreateObject("Scripting.Dictionary")
- Set List = CreateObject("System.Collections.ArrayList")
- arr = Sheets("明细").UsedRange
- For j = 1 To UBound(arr, 2) Step 2
- k = arr(1, j)
- List.Add k
- For i = 2 To UBound(arr)
- If arr(i, j) <> Empty Then
- s = arr(i, j)
- d1(s) = ""
- s = arr(i, j) & "|" & arr(1, j)
- d(s) = arr(i, j + 1)
- End If
- Next
- Next
- With Sheets("汇总")
- .[c1].Resize(, 20) = ""
- .UsedRange.Offset(1, 1).Clear
- .[c1].Resize(, List.Count) = List.toArray
- .[b2].Resize(d1.Count, 1) = WorksheetFunction.Transpose(d1.keys)
- arr = .[b1].Resize(d1.Count + 1, List.Count + 1)
- For i = 2 To UBound(arr)
- For j = 2 To UBound(arr, 2)
- s = arr(i, 1) & "|" & arr(1, j)
- If d.Exists(s) Then
- arr(i, j) = d(s)
- End If
- Next
- Next
- .[b1].Resize(d1.Count + 1, List.Count + 1) = arr
- .[b1].Resize(d1.Count + 1, List.Count + 1).Borders.LineStyle = 1
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|