|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 统计()
Application.ScreenUpdating = False
Dim ar As Variant
Dim d As Object
Dim br()
Set d = CreateObject("scripting.dictionary")
With Sheets("基本资料")
r = .Cells(Rows.Count, 3).End(xlUp).Row
If r < 2 Then MsgBox "基本资料为空!": End
ar = .Range("c1:t" & r)
End With
ReDim br(1 To UBound(ar), 1 To 16)
For i = 2 To UBound(ar)
If ar(i, 1) <> "" Then
If ar(i, 2) <> "聘用工" And ar(i, 2) <> "厨房" 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
br(t, 2) = br(t, 2) + 1
For j = 5 To UBound(ar, 2)
br(t, j - 2) = br(t, j - 2) + ar(i, j)
Next j
End If
End If
Next i
If k = "" Then MsgBox "没有需要汇总的数据!": End
With Sheets("非厨非聘用工")
rs = .Cells(Rows.Count, 3).End(xlUp).Row
If rs >= 5 Then .Range("b5:q" & rs) = Empty
.[b5].Resize(k, UBound(br, 2)) = br
End With
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub |
|