|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 ykcbf1100 于 2024-6-18 08:30 编辑
参与一下。。。- Sub ykcbf() '//2024.6.18
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set d = CreateObject("Scripting.Dictionary")
- a = [{"政史地","物化生","物化地","政史生"}]
- b = [{420,190,70,100}]
- With Sheets("Sheet1")
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .[a1].Resize(r, 3)
- End With
- ReDim brr(1 To r, 1 To UBound(a) * 3)
- For x = 1 To UBound(a)
- d.RemoveAll
- n = n + 3
- m = 0
- For i = 2 To UBound(arr)
- If arr(i, 3) = a(x) Then
- If arr(i, 2) <= b(x) Then
- s = a(x) & "|" & arr(i, 1)
- If Not d.exists(s) Then
- m = m + 1
- d(s) = m
- brr(m, n - 2) = a(x)
- brr(m, n - 1) = arr(i, 1)
- brr(m, n) = 1
- Else
- r = d(s)
- brr(r, n) = brr(r, n) + 1
- End If
- End If
- End If
- Next
- Next
- With Sheets("名次统计")
- .UsedRange.UnMerge
- .UsedRange.Offset(1).ClearContents
- .[a2].Resize(100, n) = brr
- zr = Array(1, 4, 7, 10)
- For j = 0 To UBound(zr)
- r = .Cells(Rows.Count, zr(j)).End(3).Row
- Dim rng As Range
- For i = r To 2 Step -1
- Set rng = ActiveSheet.Cells(i, zr(j))
- Set Rng1 = rng.Offset(-1)
- If rng = Rng1 Then
- ActiveSheet.Cells(i, zr(j)).Offset(-1).Resize(2).Merge
- End If
- Next
- Next
- End With
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|