Finding a comment text
Hi Stefi,
Try limiting the search to cells with comments, e.g.:
'============
Public Sub AAA()
Dim rng As Range
Dim rCell As Range
Const sStr As String = "Hi" '<<== Your search string
Set rng = Range("A1:D100").SpecialCells(xlCellTypeComments)
On Error GoTo 0
If Not rng Is Nothing Then
For Each rCell In rng.Cells
If InStr(1, rCell.Comment.Text, sStr, vbTextCompare) Then
'do something, e.g.:
MsgBox rCell.Address
End If
Next rCell
End If
End Sub
'<<============
---
Regards,
Norman
"Stefi" wrote in message
...
Hi all,
Is there a better way to find a certain comment text (say in a variable
named commtext) within a range than checking each cell in the range with
an
If Cell.Comment.Text = commtext then
statement in a For each ... cycle?
Thanks,
Stefi
|