|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub test()
- Dim d, d2, arr, brr
- Application.ScreenUpdating = False
- Set d = CreateObject("scripting.dictionary")
- Set d2 = CreateObject("scripting.dictionary")
- With Sheets("重量金额合计")
- .Columns(1).Clear
- For i = 3 To Sheets.Count
- arr = Sheets(i).UsedRange
- For u = 2 To UBound(arr)
- If arr(u, 15) <> "" Then
- d(arr(u, 15)) = ""
- d2(Sheets(i).Name & arr(u, 15) & "合计重量") = d2(Sheets(i).Name & arr(u, 15) & "合计重量") + arr(u, 25)
- d2(Sheets(i).Name & arr(u, 15) & "含税金额") = d2(Sheets(i).Name & arr(u, 15) & "含税金额") + arr(u, 29)
- End If
- Next
- Next
- .Range("a2") = "材料"
- .Range("a3").Resize(d.Count) = WorksheetFunction.Transpose(d.Keys)
- brr = .UsedRange
- For i = 3 To UBound(brr)
- For u = 3 To UBound(brr, 2) Step 3
- For o = 1 To 2
- If o = 1 Then
- If d2.exists(brr(1, u) & brr(i, 1) & brr(2, u)) Then brr(i, u) = d2(brr(1, u) & brr(i, 1) & brr(2, u))
- Else:
- If d2.exists(brr(1, u) & brr(i, 1) & brr(2, u + 1)) Then brr(i, u + 1) = d2(brr(1, u) & brr(i, 1) & brr(2, u + 1))
- End If
- Next
- Next
- Next
- .Range("a1").Resize(UBound(brr), UBound(brr, 2)) = brr
- End With
- Set d = Nothing
- Set d2 = Nothing
- Set arr = Nothing
- Set brr = Nothing
- Application.ScreenUpdating = True
- End Sub
复制代码 我稍微更改了一下你的表格。
|
评分
-
1
查看全部评分
-
|