|
|
仅在出库表写入重量,其它不改变
- Sub 食材汇总()
- Dim d, i&, j&, lastrow&, s, s1, k, ar
- Set d = VBA.CreateObject("scripting.dictionary")
- Set d("午餐") = VBA.CreateObject("scripting.dictionary")
- Set d("晚餐") = VBA.CreateObject("scripting.dictionary")
- For Each sh In Sheets
- If sh.Name Like "*第*周食谱*" Then
- lastrow = sh.Cells(Rows.Count, 1).End(3).Row - 1
- lastcol = sh.Cells(5, Columns.Count).End(xlToLeft).Column
- ar = sh.Range("a4", sh.Cells(lastrow, lastcol))
- For i = 3 To UBound(ar) - 1
- If ar(i, 1) <> "" Then s = ar(i, 1)
- For j = 2 To UBound(ar, 2) Step 4
- If ar(i, j + 1) <> "" Then
- s1 = ar(i, j + 1) & CDate(ar(1, j))
- d(s)(s1) = d(s)(s1) + ar(i, j + 3)
- End If
- Next
- Next
- End If
- Next
- For Each k In d.keys
- With Sheets(k & "出库登记表")
- lastrow = .Cells(8, "C").End(xlDown).Row
- lastcol = .Cells(2, Columns.Count).End(xlToLeft).Column
- For i = 8 To lastrow
- For j = 1 To lastcol
- rq = .Cells(2, j).Value
- If VBA.IsDate(rq) Then
- s = .Cells(i, 3) & CDate(rq)
- If d(k).exists(s) Then
- .Cells(i, j) = d(k)(s)
- End If
- End If
- Next
- Next
- End With
- Next
- Set d = Nothing
- End Sub
复制代码 |
评分
-
2
查看全部评分
-
|