|
Sub 统计()
Dim ar As Variant
Dim d As Object
Dim br()
Set d = CreateObject("scripting.dictionary")
With Sheets("出库明细")
r = .Cells(Rows.Count, 1).End(xlUp).Row
y = .Cells(1, Columns.Count).End(xlToLeft).Column
If r < 2 Then MsgBox "出库明细为空!": End
ar = .Range(.Cells(1, 1), .Cells(r, y))
End With
ReDim br(1 To UBound(ar), 1 To UBound(ar, 2))
br(1, 1) = "日期"
k = 1
For i = 2 To UBound(ar)
If ar(i, 1) <> "" Then
t = d(ar(i, 1))
If t = "" Then
k = k + 1
d(ar(i, 1)) = k
t = k
br(k, 1) = ar(i, 1)
End If
For j = 2 To UBound(ar, 2)
br(1, j) = ar(1, j)
br(t, j) = br(t, j) + IIf(ar(i, j) = "", ar(i, j) = 0, ar(i, j))
Next j
End If
Next i
With Sheets("出库日统计")
.[a1].CurrentRegion.Borders.LineStyle = 0
.[a1].CurrentRegion = Empty
.[a1].Resize(k, UBound(br, 2)) = br
.[a1].Resize(k, UBound(br, 2)).Borders.LineStyle = 1
End With
MsgBox "ok!"
End Sub
|
|