|
要求:现在是4月,要求将表“IODC”和表"EFPR"3月的数据汇总到,“汇总”表里
备注:有料号相同项就合并计算,如果是空格删除
请各位老师帮帮忙,谢谢。
- Sub 汇总()
- yf = Month(Date) - 1 '上一月
- Set d = CreateObject("scripting.dictionary")
- For k = 1 To 2
- With Sheets(k)
- r = .UsedRange.Find("料号").Row
- If k = 1 Then
- For c = .Cells(r, 256).End(xlToLeft).Column To 2 Step -1
- If Month(.Cells(r, c)) = yf Then Exit For
- Next
- Else
- For c = .Cells(r, 256).End(xlToLeft).Column To 2 Step -1
- If .Cells(r, c) = yf & "月" Then Exit For
- Next
- End If
- For i = r + 1 To .[a65536].End(3).Row
- x = .Cells(i, 1)
- d(x) = d(x) + .Cells(i, c)
- Next
- End With
- Next
- For Each x In d.keys
- If d(x) = 0 Then d.Remove (x)
- Next
- [a2].Resize(d.Count, 2) = Application.Transpose(Array(d.keys, d.items))
- [a2].Resize(d.Count, 2).Sort key1:=[b2], order1:=xlDescending
- End Sub
复制代码
|
|