|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 ykcbf1100 于 2024-5-30 15:59 编辑
参与一下。。。- Sub ykcbf() '//2024.5.30
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set d = CreateObject("Scripting.Dictionary")
- b = [{90,80,70,60,50,40,30,20,10,0}]
- With Sheets("得分")
- r = .Cells(Rows.Count, 1).End(3).Row
- arr = .[a1].Resize(r, 17)
- End With
- For j = 3 To UBound(arr, 2)
- For i = 2 To UBound(arr)
- For x = 1 To UBound(b)
- If arr(i, j) >= b(x) Then m = x + 2: Exit For
- Next
- s = arr(1, j) & "|" & arr(i, 2) & "|" & m
- If Not d.exists(s) Then
- d(s) = Array(arr(i, 17) & arr(i, j), 1)
- Else
- t = d(s)
- t(0) = t(0) & Chr(10) & arr(i, 17) & arr(i, j)
- t(1) = t(1) + 1
- d(s) = t
- End If
- Next
- Next
- On Error Resume Next
- With Sheets("汇总")
- .UsedRange.Offset(2, 2).ClearComments
- .UsedRange.Offset(2, 2).ClearContents
- arr = .UsedRange
- For i = 2 To UBound(arr)
- If arr(i, 1) = Empty Then arr(i, 1) = arr(i - 1, 1)
- For j = 3 To UBound(arr, 2)
- s = arr(i, 1) & "|" & arr(i, 2) & "|" & j
- If d.exists(s) Then
- .Cells(i, j) = d(s)(1)
- .Cells(i, j).AddCommentThreaded (d(s)(0))
- End If
- Next
- Next
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|