|
人数统计
- Sub ykcbf() '//2024.7.17 人数统计
- Application.ScreenUpdating = False
- Set d = CreateObject("Scripting.Dictionary")
- Set d1 = CreateObject("Scripting.Dictionary")
- num1 = 11000: num2 = 19000
- With Sheets("原始数据")
- r = .Cells(Rows.Count, 2).End(3).Row
- c = .UsedRange.Columns.Count
- arr = .[a1].Resize(r, c)
- End With
- For i = 2 To UBound(arr)
- For j = 3 To UBound(arr, 2) Step 2
- s = arr(i, 2) & "|" & arr(1, j)
- If arr(i, j + 1) <= num1 Then
- d(s) = d(s) + 1
- End If
- If arr(i, j + 1) <= num2 Then
- d1(s) = d1(s) + 1
- End If
- Next
- Next
- With Sheets("统计结果")
- r = .Cells(Rows.Count, 2).End(3).Row
- c = .UsedRange.Columns.Count
- arr = .[a1].Resize(r, c)
- For i = 2 To UBound(arr) Step 2
- For j = 3 To UBound(arr, 2)
- s = arr(i, 1) & "|" & arr(1, j)
- arr(i, j) = d(s)
- arr(i + 1, j) = d1(s)
- Next
- Next
- .[a1].Resize(r, c) = arr
- End With
- Set d = Nothing
- Set d1 = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|