+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    02-15-2009
    Location
    Newbury Park, California
    MS-Off Ver
    Excel 2003
    Posts
    9

    How Can I Highlight with Different Colors with Keyboard Shortcut

    Hello,

    I am looking for a way to easily highlight a selected text with either green or pink without having to click on the highlighter icon, move the mouse over the desired color, and then click. I would like two keyboard shortcuts - one for pink and one for green.

    If someone can point me in the right direction or create a macro for me, I would be very grateful.

    Thanks

  2. #2
    Forum Moderator teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    2003 & 2010
    Posts
    10,043

    Re: How Can I Highlight with Different Colors with Keyboard Shortcut

    Hi,

    you can easily create your own macros for that, using the Word Macro recorder.

    1. highlight a word or phrase
    2. Start the macro recorder (Tools - Macro - Record new macro)
    3. assign the macro a name, define if it should be stored in Normal.dot or the current file, assign a keyboard shortcut (after all this, you'll close the dialogs and end up with a recording icon)
    4. format your selected text
    5. Stop the macro recorder

    Now you have a macro that formats selected text upon pressing the keys you specified.



    hth
    teylyn
    Microsoft MVP - Excel
    At Excelforum, you can say "Thank you!" by clicking the icon below the post.

    Avoid pie charts with more than two data points. Why? See here (pdf, 559 kb). The only acceptable pie chart is here.

  3. #3
    Forum Moderator shg's Avatar
    Join Date
    06-21-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2007
    Posts
    25,137

    Re: How Can I Highlight with Different Colors with Keyboard Shortcut

    In the alternative, you can click the Fill button, and tear off the Fill Color palette to float on the worksheet. Then you can select any color with a single mouse click.
    Microsoft MVP - Excel
    Entia non sunt multiplicanda sine necessitate

  4. #4
    Registered User
    Join Date
    02-15-2009
    Location
    Newbury Park, California
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: How Can I Highlight with Different Colors with Keyboard Shortcut

    The macro solution worked great!

    However, because I'm a bit picky, I want a different shade of green and pink...

    Right now, the macro's code is here:

    Code:
    Sub PinkHighlight()
    '
    ' PinkHighlight Macro
    ' Highlights the selected text pink.
    '
        Options.DefaultHighlightColorIndex = wdPink
        Selection.Range.HighlightColorIndex = wdPink
    End Sub
    How can I replace wdPink with hex or some other method in order to specify a color to a great specificity?

  5. #5
    Forum Moderator teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    2003 & 2010
    Posts
    10,043

    Re: How Can I Highlight with Different Colors with Keyboard Shortcut

    Hi,

    with the highlight you are restricted to the colors you see in the palette (and white).

    If you want a larger palette, you could use the background color of the text instead of the highlight functionality. This would open up all the colors in the palette. Something like

    Code:
    Sub MyLights()
        With Selection.Font
            With .Shading
                .ForegroundPatternColor = wdColorAutomatic
                .BackgroundPatternColor = wdColorLightGreen
            End With
        End With
    End Sub
    You will not be able to undo the color with the Highlight button, though, you'll either have to record another macro to set the background color back to nothing or go through the Format - Borders and Shading dialog.

    The named colors can be found in the Visual basic editor help, just enter "BackgroundPatternColor Property" as the help term and drill down do the wdColor list.

    Or, instead of the color name, you can use the RGB() function as in

    Code:
    .BackgroundPatternColor = RGB(93, 118, 141)
    hth
    teylyn
    Microsoft MVP - Excel
    At Excelforum, you can say "Thank you!" by clicking the icon below the post.

    Avoid pie charts with more than two data points. Why? See here (pdf, 559 kb). The only acceptable pie chart is here.

  6. #6
    Registered User
    Join Date
    07-13-2010
    Location
    St. Louis, MO USA
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: How Can I Highlight with Different Colors with Keyboard Shortcut

    I know this is an old thread but try this for your macro. It toggles between black, blue, and red.
    Sub Color_rows()
    '
    ' Color_rows Macro
    ' Toggle between blue/red/black
    '

    Select Case Selection.Font.ColorIndex
    Case xlColorIndexAutomatic
    Selection.Font.ColorIndex = 5
    Case 5
    Selection.Font.ColorIndex = 3
    Case Else
    Selection.Font.ColorIndex = xlColorIndexAutomatic
    End Select
    End Sub

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0