- Sub test()
- Dim r%, i%
- Dim arr, brr(1 To 5)
- Dim d As Object
- Set d = CreateObject("scripting.dictionary")
- With Worksheets("学校统计")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- .Range("b3:b" & r).ClearContents
- crr = .Range("a3:b" & r)
- For i = 1 To UBound(crr)
- d(crr(i, 1)) = i
- Next
- End With
- With Worksheets("数据统计")
- .Range("a4,c4:c9,e4:e9") = ""
- brr(1) = .Range("a4:e9")
- .Range("b12:b14") = ""
- brr(2) = .Range("b12:b14")
- .Range("b23:d46") = ""
- brr(4) = .Range("b23:d46")
- .Range("b50:d72") = ""
- brr(5) = .Range("b50:d72")
- End With
- With Worksheets("收费汇总")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a2:aa" & r)
- End With
- For i = 1 To UBound(arr)
- If arr(i, 5) = "男" Then
- m = 1
- Else
- m = 3
- End If
- If arr(i, 9) = "是" Then
- n = 1
- Else
- n = 2
- End If
- If arr(i, 7) = "文" Then
- l = 1
- Else
- l = 2
- End If
- brr(1)(1, 1) = brr(1)(1, 1) + 1
- brr(1)(m, 3) = brr(1)(m, 3) + 1
- brr(1)(m + n - 1, 5) = brr(1)(m + n - 1, 5) + 1
- brr(1)(n + 4, 3) = brr(1)(n + 4, 3) + 1
- brr(2)(l, 1) = brr(2)(l, 1) + 1
- brr(2)(3, 1) = brr(2)(3, 1) + 1
- xh = Application.Match(arr(i, 23) + arr(i, 25), Array(0, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520, 530, 540, 550, 560, 570, 580, 590, 600))
- If Not IsError(xh) Then
- brr(4)(23 - xh, l + 1) = brr(4)(23 - xh, l + 1) + 1
- brr(4)(24, l + 1) = brr(4)(24, l + 1) + 1
- brr(4)(23 - xh, 1) = brr(4)(23 - xh, 1) + 1
- brr(4)(24, 1) = brr(4)(24, 1) + 1
- End If
- xh = Application.Match(arr(i, 25), Array(0, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520, 530, 540, 550, 560, 570, 580, 590, 600))
- If Not IsError(xh) Then
- brr(5)(23 - xh, l + 1) = brr(5)(23 - xh, l + 1) + 1
- brr(5)(23, l + 1) = brr(5)(23, l + 1) + 1
- brr(5)(23 - xh, 1) = brr(5)(23 - xh, 1) + 1
- brr(5)(23, 1) = brr(5)(23, 1) + 1
- End If
- If d.exists(arr(i, 8)) Then
- m = d(arr(i, 8))
- crr(m, 2) = crr(m, 2) + 1
- End If
- Next
- With Worksheets("数据统计")
- .Range("a4:e9") = brr(1)
- .Range("b12:b14") = brr(2)
- .Range("b23:d46") = brr(4)
- .Range("b50:d72") = brr(5)
- End With
- With Worksheets("学校统计")
- .Range("a3").Resize(UBound(crr), UBound(crr, 2)) = crr
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- .Cells(r, 2).FormulaR1C1 = "=SUM(R3C:R[-1]C)"
- End With
- End Sub
复制代码 |