• 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:
    Code:
    Option Explicit
    Private Const lDefaultCommentColor As Long = 14811135
    Private Sub RestoreCommentColor(wks As Worksheet)
    'Author       : Ken Puls (www.excelguru.ca)
    '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
    Instructions:
    Call the RestoreCommentColor subroutine (passing it a worksheet variable) from within your code, as shown in the examples below:
    Code:
    Sub RestoreActiveComments()
    'Author       : Ken Puls (www.excelguru.ca)
    'Macro Purpose: Restore the Comment colour for the active sheet
        
        Call RestoreCommentColor(ActiveSheet)
    
    End Sub
    
    Sub RestoreAllComments()
    'Author       : Ken Puls (www.excelguru.ca)
    '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:
    Code:
    ?RGB(0, 255, 0)
    The resulting number is the Long that you wish to use for your colour constant in the code.
  • MVP Logo
  •  Donations

    If you like our website and would like to give something in return, you can make a donation. All donations are gratefully received and go to support the site.


    Select your preferred currency and donation amount, then click the donate button.

  • Recent Forum Posts

    Colo

    How to Rename a File from English to Other Language?

    Yeah, some massive HTML conversion is my line. In other words, most of difficult things can be done with Excel alone like this time. Well done, Excel!...

    Colo Today, 07:36 AM Go to last post
    Ken Puls

    Link a series name to a cell using Excel 2010 VBA

    Hi there,

    I recorded linking the title to a cell and it came back with the following. Does this help?

    Code:
        ActiveChart.SetElement
    ...

    Ken Puls Today, 04:06 AM Go to last post
    Ken Puls

    How to Rename a File from English to Other Language?

    Colo, that was way too easy... I was expecting some massive HTML conversion, or a huge engine to compare each character against a library of Chr codes!...

    Ken Puls Today, 04:02 AM Go to last post
    Ken Puls

    Shared file\macro & IP address

    Oh, and as for the max number of users who can access the file in the shared folder at once...

    • For reading, I believe it's unlimited. (The second and
    ...

    Ken Puls Today, 03:59 AM Go to last post
    Ken Puls

    Shared file\macro & IP address

    ibrahimaa,

    There is no one-line way to get your IP address the way you are getting the username. So you're going to need more code than...

    Ken Puls Today, 03:56 AM Go to last post