|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- 以此份代码为准,当初没有考虑到合并单元格的情形
- Sub KeyIn_Maket()
- Dim arr, i%, j%, brr, arr_data, arr_list$, Mrow%, Mcol%
- Dim dic As Object
- Set dic = CreateObject("scripting.dictionary")
- Application.ScreenUpdating = False
- arr_data = Sheets("得分").UsedRange
- For i = 2 To UBound(arr_data)
- For j = 3 To 6
- Key = arr_data(1, j) & arr_data(i, 2) & hd(arr_data(i, j))
- If Not dic.exists(Key) Then
- dic(Key) = arr_data(i, 17) & " " & arr_data(i, j)
- Else
- arr_list = dic(Key)
- dic(Key) = arr_list & "|" & arr_data(i, 17) & " " & arr_data(i, j)
- arr_list = ""
- End If
- Next j
- Next i
- With Sheets("汇总")
- arr = .Cells(1.1).CurrentRegion
- For i = 3 To UBound(arr) Step 3
- arr(i + 1, 1) = arr(i, 1)
- arr(i + 2, 1) = arr(i, 1)
- Next i
- For i = 3 To UBound(arr)
- For j = 3 To UBound(arr, 2)
- If Len(.Cells(i, j).Value) > 0 Then
- Key = arr(i, 1) & arr(i, 2) & j
- If Not .Cells(i, j).Comment Is Nothing Then .Cells(i, j).Comment.Delete
- arr_list = dic(Key)
- .Cells(i, j).AddComment Replace(arr_list, "|", vbCrLf)
- With .Cells(i, j).Comment.Shape.TextFrame
- .Characters.Font.Bold = True
- .Characters.Font.Name = "Arial"
- .Characters.Font.Size = 12
- .AutoSize = True
- End With
- End If
- Next j
- Next i
- End With
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|