|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
参与一下。。。- Sub ykcbf() '//2024.3.12
- Dim arr, d
- Application.ScreenUpdating = False
- Set d = CreateObject("Scripting.Dictionary")
- With Sheets("合同")
- .UsedRange.Offset(1).Clear
- r = .Cells(Rows.Count, 1).End(3).Row
- c = .Cells(r, 1).End(2).Column
- c = IIf(r = 1, c - 2, c)
- arr = .[a1].Resize(r, c)
- ReDim brr(1 To 1000, 1 To 20)
- If r > 1 Then
- For i = 2 To UBound(arr)
- s = arr(i, 1)
- d(s) = ""
- Next
- End If
- End With
- On Error Resume Next
- With Sheets("序时")
- r = .Cells(.Rows.Count, "a").End(xlUp).Row
- arr = .[a1].Resize(r, 7)
- End With
- For i = 2 To UBound(arr)
- s = arr(i, 1)
- If s <> Empty Then
- If Not d.exists(s) Then
- m = m + 1
- brr(m, 1) = arr(i, 1)
- brr(m, 2) = arr(i, 2)
- brr(m, c + 1) = arr(i, 5)
- d(s) = arr(i, 6)
- End If
- End If
- Next
- With Sheets("合同")
- r = .Cells(Rows.Count, 1).End(3).Row
- .Cells(r + 1, 1).Resize(m, c + 1) = brr
- .Cells(r + 1, 1).Resize(m, c + 1).Borders.LineStyle = 1
- For i = 2 To r + m
- s = .Cells(i, 1)
- .Cells(i, c + 1).ClearComments
- .Cells(i, c + 1).AddComment
- .Cells(i, c + 1).Comment.Text Text:=d(s)
- Next
- End With
- Sheets("序时").UsedRange.Offset(1) = ""
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|