|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
统计表1的代码:
- Sub test1() '统计表1
- Dim r%, i%
- Dim arr, brr
- Dim d As Object
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set d = CreateObject("scripting.dictionary")
- Set d1 = CreateObject("scripting.dictionary")
- With Worksheets("网上表")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- crr = .Range("a3:i" & r)
- For i = 1 To UBound(crr)
- d1(CStr(crr(i, 9))) = i
- Next
- End With
- With Worksheets("原有表")
- r = .Cells(.Rows.Count, 7).End(xlUp).Row
- arr = .Range("a2:i" & r)
- For i = 1 To UBound(arr)
- If Not d.exists(arr(i, 7)) Then
- ReDim brr(1 To 22)
- brr(1) = arr(i, 7)
- Else
- brr = d(arr(i, 7))
- End If
- brr(3) = brr(3) + 1
- If arr(i, 1) = "不报名" Then
- brr(4) = brr(4) + 1
- brr(5) = brr(5) & "," & arr(i, 8)
- Else
- If d1.exists(CStr(arr(i, 9))) Then
- m = d1(arr(i, 9))
- brr(6) = brr(6) + 1
- brr(7) = brr(7) & "," & arr(i, 8)
- brr(10) = brr(10) + 1
- brr(11) = brr(11) + 1
- brr(12) = brr(12) & "," & arr(i, 8)
- If crr(m, 2) = "完善" Then
- brr(13) = brr(13) + 1
- brr(14) = brr(14) & "," & crr(m, 8)
- Else
- brr(15) = brr(15) + 1
- brr(16) = brr(16) & "," & crr(m, 8)
- End If
- If crr(m, 3) = "未报名" Then
- brr(17) = brr(17) + 1
- brr(18) = brr(18) & "," & crr(m, 8)
- Else
- brr(19) = brr(19) + 1
- brr(20) = brr(20) & "," & crr(m, 8)
- End If
- Else
- brr(8) = brr(8) + 1
- brr(9) = brr(9) & "," & arr(i, 8)
- End If
- End If
- d(arr(i, 7)) = brr
- Next
- End With
- ReDim drr(1 To d.Count, 1 To UBound(brr))
- ReDim grr(1 To UBound(brr))
- m = 0
- For Each aa In d.keys
- brr = d(aa)
- For Each x In Array(5, 7, 9, 12, 14, 16, 18, 20)
- If Len(brr(x)) <> 0 Then
- brr(x) = Mid(brr(x), 2)
- End If
- Next
- For Each x In Array(3, 4, 6, 8, 10, 11, 13, 15, 17, 19)
- grr(x) = grr(x) + brr(x)
- Next
- If brr(8) + brr(17) <> 0 Then
- brr(21) = brr(8) & "+" & brr(17) & "=" & brr(8) + brr(17)
- End If
- If Len(brr(9)) <> 0 Then
- brr(22) = brr(9)
- End If
- If Len(brr(18)) <> 0 Then
- brr(22) = brr(22) & "," & brr(18)
- End If
- If Len(brr(22)) <> 0 Then
- brr(22) = Mid(brr(22), 2)
- End If
- m = m + 1
- For j = 1 To UBound(brr)
- drr(m, j) = brr(j)
- Next
- Next
- grr(21) = grr(8) & "+" & grr(17) & "=" & grr(8) + grr(17)
- With Worksheets("统计表1")
- .Range("a6:v" & .Rows.Count).Clear
- .Range("a6").Resize(1, UBound(grr)) = grr
- .Range("a7").Resize(UBound(drr), UBound(drr, 2)) = drr
- With .Range("a3").Resize(3 + 1 + UBound(drr), UBound(drr, 2))
- .Borders.LineStyle = xlContinuous
- With .Font
- .Name = "微软雅黑"
- .Size = 10
- End With
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- End With
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|