|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub 汇总()
- Dim sh As Worksheet
- Set d = CreateObject("scripting.dictionary")
- arr = Sheets("每日出货").Range("a3:a" & Sheets("每日出货").Cells(Rows.Count, 1).End(3).Row)
- For i = 1 To UBound(arr) '辅助列和行的关系
- d(arr(i, 1)) = i
- Next
- ReDim brr(1 To UBound(arr), 1 To 1)
- For Each t In Array("销售单列表", "出货信息", "入库信息")
- ReDim brr(1 To UBound(arr), 1 To 1)
- Set sh = Sheets(t)
- If t = "销售单列表" Then c1 = "G": c2 = "R": c = 27 'c1:数据列,c2:辅助列,c:本表中输出的列
- If t = "出货信息" Then c1 = "E": c2 = "O": c = 28
- If t = "入库信息" Then c1 = "D": c2 = "F": c = 74 'BV列
- r = sh.Range(c2 & Cells.Rows.Count).End(3).Row
- mydata = sh.Range(c1 & "1:" & c2 & r)
- cmax = UBound(mydata, 2) '源数据的最大列(辅助列)
- For i = 2 To r
- k = mydata(i, cmax)
- If d(k) > 0 Then brr(d(k), 1) = brr(d(k), 1) + mydata(i, 1)
- Next
- Cells(3, c).Resize(UBound(arr), 1) = brr
-
- If t = "销售单列表" Then '是否报关
- c = 77 'BY列
- ReDim brr(1 To UBound(arr), 1 To 1)
- For i = 2 To r
- k = mydata(i, cmax)
- If mydata(i, 6) <> "" And d(k) > 0 Then brr(d(k), 1) = mydata(i, 6)
- Next
- Cells(3, c).Resize(UBound(arr), 1) = brr
- End If
- Next
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|