|
[广告] 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("出入库清单")
rs = .Cells(Rows.Count, 1).End(xlUp).Row
br = .Range("a1:h" & rs)
End With
With Sheets("明细账")
.UsedRange.Offset(2).Clear
y = .Cells(2, Columns.Count).End(xlToLeft).Column
ar = .Range(.Cells(1, 1), .Cells(rs, y))
For j = 2 To UBound(ar, 2) Step 2
If Trim(ar(1, j)) <> "" Then
d(Trim(ar(1, j))) = j
End If
Next j
k = 2
For i = 2 To UBound(br)
If Trim(br(i, 2)) <> "" Then
t = d(Trim(br(i, 2)))
If t = "" Then
k = k + 1
d(Trim(br(i, 2))) = k
t = k
ar(k, 1) = br(i, 2)
End If
If Trim(br(i, 4)) <> "" Then
lh = d(Trim(br(i, 4)))
If lh <> "" Then
ar(t, lh) = ar(t, lh) + br(i, 6)
ar(t, lh + 1) = ar(t, lh + 1) + br(i, 5)
End If
End If
End If
Next i
.[a1].Resize(k, y) = ar
.[a1].Resize(k, y).Borders.LineStyle = 1
End With
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub |
评分
-
2
查看全部评分
-
|