|
根据实际情况自行调节两个区域。
- Sub 比较()
- On Error Resume Next
- Dim Rng As Range, CmpRng As Range
- Set Rng = Range("A4").Resize(1, 10) '要设置批注的区域
- Set CmpRng = Range("L4").Resize(1, 10) '供比较的区域(大小需与Rng一致)
- For i = 1 To Rng.Cells.Count
- With Rng.Cells(i)
- .Comment.Delete
- If .Value <> "" And .Value = CmpRng.Cells(i).Value Then
- .AddComment
- ' .Comment.Visible = True
- .Comment.Text Text:="相同值:" & CmpRng.Cells(i).Address(0, 0)
- .Comment.Shape.TextFrame.AutoSize = True
- End If
- End With
- Next
- End Sub
复制代码 |
|