Restore Default Comment Colour

Restores default yellow colour for all comment on the worksheet. Can easily be modified to change all comments to a different colour by changing the value of the lDefaultCommentColor variable.

Where to place the code:

This code goes in a standard module.

Code required:

Option Explicit
Private Const lDefaultCommentColor As Long = 14811135
Private Sub RestoreCommentColor(wks As Worksheet)
'Author       : Ken Puls (
'Macro Purpose: To return all comments to the specified color
    Dim cl As Range

    On Error Resume Next
    For Each cl In wks.UsedRange.SpecialCells(xlCellTypeComments)
        cl.Comment.Shape.Fill.ForeColor.RGB = lDefaultCommentColor
    Next cl

    On Error GoTo 0

End Sub


Call the RestoreCommentColor subroutine (passing it a worksheet variable) from within your code, as shown in the examples below:

Sub RestoreActiveComments()
'Author       : Ken Puls (
'Macro Purpose: Restore the Comment colour for the active sheet
    Call RestoreCommentColor(ActiveSheet)

End Sub

Sub RestoreAllComments()
'Author       : Ken Puls (
'Macro Purpose: Restore the Comment colour for the all sheets
    Dim wks As Worksheet

    For Each wks In ActiveWorkbook.Worksheets
        Call RestoreCommentColor(wks)
    Next wks

End Sub

NOTE: To find out the Long value for the desired colour, first locate an RGB decimal colour code. (An excellent source for this is found here.) Enter the following in the immediate window, replacing "0, 255, 0" with your desired colour, and hit Enter:

?RGB(0, 255, 0)

The resulting number is the Long that you wish to use for your colour constant in the code.



Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Latest Posts