Searching within comments added to cells
Hi,
A starter which looks for text "comment" in comments. If found, it
makes the comment visible - I don't know how you get the cell address.
Sub FindComments()
Dim c As Object, ws As Worksheet, resp
Dim cFound As Boolean
For Each ws In Worksheets
ws.Activate
cFound = False
For Each c In ActiveSheet.Comments
If InStr(1, c.Text, "Comment") < 0 Then
resp = MsgBox(ws.Name & vbCrLf & vbCrLf & "Do you want to continue
search?", vbYesNo, "Search for comments")
cFound = True
If resp = vbNo Then
c.Visible = True
Exit Sub
End If
End If
Next c
If Not cFound Then
MsgBox "No comment found in " & ws.Name
End If
Next ws
End Sub
HTH
"red6000" wrote:
Is it possible to write VBA code that will search inside the comments
attached to a cell in excel for each sheet in the workbook.
The number and names of the sheets will constantly be changing.
Ideally what I'd like to do is something like:
1. Go to first sheet in workbook
2. for each sheet in workbook search the comments for desired info
3. On finding result return message stating the sheet name and cell that
the comment is attached to and the choice to end searching here and go to
that cell or continue searching
4. On not finding result return message with simple 'OK' button and end
the macro.
Thanks for any help/pointers in the right direction.
|