PDA

View Full Version : find all cell containing comments



lior03
11-27-2005, 11:56 AM
hello
i am trying to find all cells in a workbook that contain
a comment in order to recalculate and change comments if necessary.
i have a macro that show formula in cell as a comment-commentalony
my macro is:
Sub ela()
Dim cell As Range
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
If cell.Comment.Visible = True Then
commentalony
End If
Next
End Sub

commentalony will look into the cell
and put a new comment if necessary
before i close the workbook.
my question- how do i make excel loop through all
sheets and find all cell that contain a comment
thanks

malik641
11-27-2005, 12:04 PM
Dim cmt As Comment

For Each cmt In ActiveSheet.Comments
MsgBox cmt.Text
Next cmt


To get you started :thumb

Zack Barresse
11-28-2005, 09:32 AM
Hey there,

Is this what you're looking for? ...

Sub nnnn()
Dim ws as Worksheet
Dim cm as Comment
Dim tmp As String
Application.ScreenUpdating = False
'Change to your comment header, if applicable
tmp = "Zack:" & Chr(10)
For Each ws In ActiveWorkbook.Worksheets
For Each cm in ws.Comments
'check if comment equals formula
If tmp & ws.Range(cm.Parent.Address).Formula <> cm.Text Then
'change comment to match formula
cm.Text tmp & ws.Range(cm.Parent.Address).Formula
End If
Next cm
Next ws
Application.ScreenUpdating = True
End Sub