|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
参与一下。。。
- Sub ykcbf() '//2024.6.19 多表排重汇总
- Application.ScreenUpdating = False
- Set d = CreateObject("Scripting.Dictionary")
- Set d1 = CreateObject("Scripting.Dictionary")
- Set sh = ThisWorkbook.Sheets("汇总表")
- sh.UsedRange.Offset(52).ClearContents
- For Each sht In Sheets
- If InStr(sht.Name, "对比表") Then
- With sht
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .[a1].Resize(r, 17)
- For i = 6 To UBound(arr)
- If Val(arr(i, 1)) Then
- s = arr(i, 3) & "|" & arr(i, 4) & "|" & arr(i, 5)
- d1(s) = ""
- s = arr(i, 3) & "|" & arr(i, 4) & "|" & arr(i, 5) & "|" & .Name
- If Not d.exists(s) Then
- d(s) = Array(arr(i, 9), arr(i, 13))
- End If
- End If
- Next
- End With
- End If
- Next
- ReDim brr(1 To d1.Count, 1 To 4)
- For Each k In d1.keys
- m = m + 1
- t = Split(k, "|")
- brr(m, 1) = m
- brr(m, 2) = t(0)
- brr(m, 3) = t(1)
- brr(m, 4) = t(2)
- Next
- With sh
- .[a53].Resize(m, 4) = brr
- r = .Cells(Rows.Count, 1).End(3).Row
- For i = 53 To r
- For j = 5 To 18 Step 2
- s = .Cells(i, 2) & "|" & .Cells(i, 3) & "|" & .Cells(i, 4) & "|" & .Cells(52, j)
- If d.exists(s) Then
- .Cells(i, j) = d(s)(0)
- .Cells(i, j + 1) = d(s)(1)
- End If
- Next
- Next
- End With
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|