Hi all,
I hope someone can help me...
I have some code which looks at each cell in the selected range, and if the cell value is higher than that of row 3 of the same column, it will add a comment to that cell.
It currently works but only now I have made the loop activate each cell - but I'm sure this shouldn't be necessary. Can anyone see why it doesn't work when i take out the rCell.activate?
I hope someone can help me...
I have some code which looks at each cell in the selected range, and if the cell value is higher than that of row 3 of the same column, it will add a comment to that cell.
It currently works but only now I have made the loop activate each cell - but I'm sure this shouldn't be necessary. Can anyone see why it doesn't work when i take out the rCell.activate?
Code:
Sub ValueToComment()
Application.ScreenUpdating = False
Dim rCell As Range
Dim b As Range
For Each rCell In Selection
rCell.Activate
res = rCell.Offset(0, 1).Text
a = ActiveCell.Row
Set b = rCell.Offset((-a + 3), 0)
With rCell
If rCell.Value < b Then
On Error Resume Next
.Comment.Delete
On Error GoTo 0
.ClearComments
.AddComment
.Comment.Text Text:=res
.Comment.Visible = False
.Comment.Shape.TextFrame.AutoSize = True
Else
On Error Resume Next
.Comment.Delete
On Error GoTo 0
.ClearComments
' .AddComment
' .Comment.Text Text:=res
' .Comment.Visible = False
' .Comment.Shape.TextFrame.AutoSize = True
End If
End With
Next
Set rCell = Nothing
Application.ScreenUpdating = True
End Sub
Last edited by a moderator: