|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub 汇总()
- Application.ScreenUpdating = False
- Dim ar As Variant, br As Variant
- Dim d As Object
- Set d = CreateObject("scripting.dictionary")
- With Sheets("Sheet2")
- r = .Cells(Rows.Count, 1).End(xlUp).Row
- ar = .Range("a2:o" & r)
- End With
- With Sheets("Sheet1")
- rs = .Cells(Rows.Count, 1).End(xlUp).Row
- If rs < 3 Then MsgBox "请现在目标表A列输入编码": End
- .Range("k3:l" & rs) = Empty
- br = .Range("a2:l" & rs)
- For i = 2 To UBound(br)
- If Trim(br(i, 1)) <> "" Then
- d(Trim(br(i, 1))) = i
- End If
- Next i
- For i = 2 To UBound(ar)
- If Trim(ar(i, 1)) <> "" Then
- xh = d(Trim(ar(i, 1)))
- If xh <> "" Then
- br(xh, 11) = br(xh, 11) + ar(i, 13)
- br(xh, 12) = br(xh, 12) + ar(i, 15)
- End If
- End If
- Next i
- .[k2].Resize(UBound(br), 1) = Application.Index(br, 0, 11)
- .[l2].Resize(UBound(br), 1) = Application.Index(br, 0, 12)
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "ok!"
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|