|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
练习一下。。。- Sub ykcbf() '//2024.11.10
- Application.ScreenUpdating = False
- Set d = CreateObject("Scripting.Dictionary")
- With Sheets("数据")
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .[a1].Resize(r, 5)
- End With
- ReDim brr(1 To r, 1 To 8)
- For i = 2 To UBound(arr)
- s = arr(i, 1)
- p1 = IIf(arr(i, 4) = "男", 1, 0)
- p2 = IIf(arr(i, 4) = "女", 1, 0)
- If Not d.exists(s) Then
- m = m + 1
- d(s) = m
- brr(m, 1) = m
- brr(m, 2) = s
- brr(m, 3) = p1
- brr(m, 4) = p2
- brr(m, 5) = 1
- Else
- r = d(s)
- brr(r, 3) = brr(r, 3) + p1
- brr(r, 4) = brr(r, 4) + p2
- brr(r, 5) = brr(r, 5) + 1
- End If
- Next
- With Sheets("汇总")
- .[a4:h10000] = ""
- .[a4].Resize(m, 8) = brr
- .[a4].Resize(m, 8).Borders.LineStyle = 1
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|