Code to hide all comments

RAM

Well-known Member
Joined
Oct 4, 2004
Messages
1,862
Hi Guys,

I could need a code to hides all comments in the open sheet.

Thanks

RAM
 

Some videos you may like

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Chas17

Well-known Member
Joined
Oct 16, 2002
Messages
657
Try one of these

Code:
    Application.DisplayCommentIndicator = xlCommentIndicatorOnly
    
    Application.DisplayCommentIndicator = xlNoIndicator

    Application.DisplayCommentIndicator = 0

Chas
 

RAM

Well-known Member
Joined
Oct 4, 2004
Messages
1,862
Thanks Chas, I'll will. Meanwhile, what is the difference between the second and the third code?

RAM
 

RAM

Well-known Member
Joined
Oct 4, 2004
Messages
1,862
Second and third code returns the same results, but it also removes the red triangle that indicates a comment, and I'm not really enthusiastic over that. It does not only remove the triangle in the open sheet but in all sheets in all open workbooks

RAM
 

Chas17

Well-known Member
Joined
Oct 16, 2002
Messages
657

ADVERTISEMENT

RAM, that is correct, first will leave red triangle
 

Chas17

Well-known Member
Joined
Oct 16, 2002
Messages
657
RAM,
This will Hide the first 10 comments on the first sheet, which may not be Sheet1, adjust as you need.

Code:
Sub HideComments()
'9/15/2006 by Charles R. Weber
' hides first 10 comments on "first sheet" (which may NOT be Sheet1)
Dim i As Integer

For i = 1 To 10
    On Error Resume Next
    Worksheets(1).Comments(i).Visible = False
Next i
End Sub

or

Code:
Sub HideComments()
'9/15/2006 by Charles R. Weber
' hides first 10 comments on ActiveSheet
Dim i As Integer

For i = 1 To 10
    On Error Resume Next
    ActiveSheet.Comments(i).Visible = False
Next i
End Sub

Chas
 

RAM

Well-known Member
Joined
Oct 4, 2004
Messages
1,862
Thanks,

I'll try it later. I'll let you know.

RAM
 

RAM

Well-known Member
Joined
Oct 4, 2004
Messages
1,862
Thanks. The second one seems to work great. This second code is also faster than the first codes we tried out. It doesn't lag me in my tabbing down the column. The red triangle doesn't seem to disappear either.


RAM
 

Watch MrExcel Video

Forum statistics

Threads
1,114,060
Messages
5,545,761
Members
410,704
Latest member
Cobber2008
Top