|
Sub 分类统计()
Dim ar As Variant
Dim d As Object, dc As Object
Set d = CreateObject("scripting.dictionary")
Set dc = CreateObject("scripting.dictionary")
With Sheets("数据")
r = .Cells(Rows.Count, 1).End(xlUp).Row
If r < 2 Then MsgBox "数据表为空!": End
ar = .Range("a1:f" & r)
End With
With Sheets("汇总")
.UsedRange.Offset(3) = Empty
br = .Range("a2:t" & r)
For j = 2 To UBound(ar, 2) Step 2
If br(1, j) <> "" Then
dc(br(1, j)) = j
End If
Next j
k = 2
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
If ar(i, 4) <> "" Then
If IsNumeric(ar(i, 4)) Then
lh = dc(ar(i, 4))
If lh <> "" Then
If ar(i, 5) = "应届" Then
br(t, lh) = br(t, lh) + 1
br(t, 18) = br(t, 18) + 1
Else
br(t, lh + 1) = br(t, lh) + 1
br(t, 19) = br(t, 19) + 1
End If
br(t, 20) = br(t, 20) + 1
End If
End If
End If
End If
Next i
.[a2].Resize(k, UBound(br, 2)) = br
End With
End Sub
|
|