参与一下。。。
- Sub ykcbf() '//2024.9.13
- Set d = CreateObject("Scripting.Dictionary")
- Set sh = ThisWorkbook.Sheets("类型汇总")
- ReDim brr(1 To 100000, 1 To 100)
- On Error Resume Next
- For Each sht In Sheets
- If sht.Name <> sh.Name Then
- arr = sht.UsedRange
- For j = 4 To UBound(arr, 2)
- If arr(10, j) <> Empty Then
- For i = 11 To UBound(arr)
- If arr(i, j) <> Empty Then
- s = arr(1, 3) & "|" & arr(10, j) & "|" & arr(9, j) & "|" & arr(i, 1)
- If Not d.exists(s) Then
- m = m + 1
- d(s) = m
- brr(m, 1) = arr(10, j)
- brr(m, 2) = arr(1, 3)
- brr(m, 3) = arr(9, j)
- brr(m, 4) = arr(i, 1)
- brr(m, 5) = arr(i, j)
- brr(m, 12) = sht.Name
- Else
- r = d(s)
- brr(r, 5) = brr(r, 5) + arr(i, j)
- End If
- End If
- Next
- End If
- Next
- End If
- Next
- With sh
- .UsedRange.Offset(1).ClearContents
- .[a2].Resize(m, 12) = brr
- End With
- MsgBox "OK!"
- End Sub
复制代码
|