|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 统计行政参公()
Dim d As Object, dc As Object
Set d = CreateObject("scripting.dictionary")
Set dc = CreateObject("scripting.dictionary")
ar = Sheets("人员名册").[a1].CurrentRegion
Dim br()
ReDim br(1 To UBound(ar), 1 To 4)
For i = 5 To UBound(ar)
If Trim(ar(i, 7)) = "行政" Or Trim(ar(i, 7)) = "参公" Then
If Trim(ar(i, 8)) <> "" And Trim(ar(i, 19)) <> "" Then
zf = Trim(ar(i, 8)) & "|" & Trim(ar(i, 19))
t = d(zf)
If t = "" Then
k = k + 1
d(zf) = k
t = k
If Not dc.exists(Trim(ar(i, 8))) Then
br(k, 1) = ar(i, 8)
dc(Trim(ar(i, 8))) = ""
Else
br(k, 1) = ""
End If
br(k, 2) = ar(i, 19)
End If
br(t, 3) = br(t, 3) + 1
If br(t, 4) = "" Then
br(t, 4) = ar(i, 2)
Else
br(t, 4) = br(t, 4) & "、" & ar(i, 2)
End If
End If
End If
Next i
With Sheets("行政、参公分类统计")
.UsedRange.Offset(4).Clear
.[b5].Resize(k, UBound(br, 2)) = br
End With
Set d = Nothing
Set dc = Nothing
MsgBox "ok!"
End Sub
|
|