Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Replacing Background Colors in Cells.

Replacing Background Colors in Cells

Written by Allen Wyatt (last updated December 5, 2022)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365


6

Jozef is looking for a way to change background colors of specific cells in the worksheet he created. For example, he would like to find all red background cells and change them to blue or find all yellow backgrounds and change them to blue. Jozef wonders if there is an easy way to do this.

It's fairly obvious that you can change the background colors of any cells manually, so there is no need to go into that option for making the changes. What you need to do is use a simple tool, such as the Find and Replace tool, to make the color changes. Follow these steps:

  1. Press Ctrl+H to display the Replace tab of the Find and Replace dialog box.
  2. Expand the dialog box by clicking the Options button. (See Figure 1.)
  3. Figure 1. The Replace tab of the Find and Replace dialog box.

  4. Click the Format button at the right side of the Find What box. Excel displays the Find Format dialog box.
  5. Make sure the Fill tab is selected. (See Figure 2.)
  6. Figure 2. The Fill tab of the Find Format dialog box.

  7. Use the controls in the dialog box to specify the background color you want to replace.
  8. Click OK.
  9. Click the Format button at the right side of the Replace With box. Excel displays the Replace Format dialog box.
  10. Make sure the Fill tab is selected.
  11. Use the controls in the dialog box to specify the background color you used when changing the cells.
  12. Click OK.
  13. Click Replace All.

If you find yourself needing to make the same color changes over and over (for instance, always changing from red to blue), then you may be interested in using a macro to do the changes. The following example could be assigned to a shortcut key or added to the Quick Access Toolbar so you can use it quickly:

Sub ChangeColor()
    Dim rCell As Range
    If Selection.Cells.Count = 1 Then
        MsgBox "Select the range to be processed."
        Exit Sub
    End If
    For Each rCell In Selection
        If rCell.Interior.Color = RGB(255, 0, 0) Then  'red
            rCell.Interior.Color = RGB(0, 0, 255)      'blue
        End If
    Next rCell
End Sub

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (9043) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Replacing Background Colors in Cells.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Inserting the Date in a Header or Footer

Need today's date in the header or footer of your document? Here's how to get it there easily.

Discover More

Ignoring Other Applications

Do you want Excel to ignore other applications that may be running on your computer? You can configure the program to do ...

Discover More

Turning Off ScreenTips

All those little ScreenTips bug you when moving your mouse pointer over different parts of Word's interface? You can turn ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More ExcelTips (ribbon)

Accurate Font Sizes

Need to use some bizarre font size in your worksheet? Not a problem, provided it is a full or half point size.

Discover More

Formatting for Hundredths of Seconds

When you display a time in a cell, Excel normally displays just the hours, minutes, and seconds. If you want to display ...

Discover More

Indenting Cell Contents

Excel allows you to apply several types of alignments to cells. One type of alignment allows you to indent cell contents ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 8 + 7?

2024-04-06 09:16:41

Allen

You are correct, Hamlet -- there is no way to do this on a Mac. The "Format" buttons (step 3) are not available in the Mac version. Perhaps Microsoft will see fit to include them one day.

-Allen


2024-04-06 09:11:17

Hamlet

Hi,
What would be the option for Excel for Mac (Office 365 subscription)? There's no 'format' option in the Replace tab in this version. Everywhere I've looked gives me the same tip, but no alternative option for Mac. Thanks!


2021-07-28 09:22:17

Ernest Striker

Dear Allen,

Thanks a lot, changing color has never been so much fun !!!

Sincerely, Ernest Striker


2020-03-25 11:01:48

James Foote

Wow. This tip is extremely powerful.
It literally saved me hours of work.
Thanks -
Jim '


2019-12-06 08:22:11

Willy Vanhaelen

@Ruben
Replace:
For Each rCell In Selection
If rCell.Interior.Color = RGB(255, 0, 0) Then 'red
rCell.Interior.Color = RGB(0, 0, 255) 'blue
End If
Next rCell
with:
For Each rCell In Selection
If rCell.Interior.Color = RGB(255, 0, 0) Then 'red
If If Not rCell.Rows.Hidden Then
rCell.Interior.Color = RGB(0, 0, 255) 'blue
End If
End If
Next rCell


2019-12-05 14:58:21

RUBEN GUTIERREZ MARTINEZ

i have a question, per say how whould you use the vba code when you have a filter in a table? I tried your code and it works but it also color all of the other cells that have the same color but i had filtered


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.