Remove Conditional Formatting but Retain the Effects

Written by Allen Wyatt (last updated April 12, 2025)
This tip applies to Excel 2010, 2013, 2016, 2019, 2021, 2024, and Excel in Microsoft 365


3

Terry has a range of cells that use conditional formatting to shade the cells. He wonders if there is a way to remove the conditional formatting rules for those cells yet still leave the shading that was present before the rules were removed.

From everything we can tell, this must be done using a macro. Here is a simple one that will make the shading static for whatever cells you select:

Sub FreezeFormat1()
    Dim cell As Range

    For Each cell In Selection
        With cell
            If .DisplayFormat.Interior.Color <> vbWhite Then
                .Interior.Color = .DisplayFormat.Interior.Color
            End If
        End With
    Next cell
    Selection.FormatConditions.Delete
End Sub

The macro steps through each selected cell and copies the interior cell color, as displayed, to the actual interior color. It then deletes any conditional formatting rules in the cell. The macro checks to see if the displayed interior cell color is white or not because if it is white, and it is copied, then it makes the cell appear as if the gridlines have been deleted.

Of course, the cell shading could also be due to shading in the cell. The macro can be expanded to freeze the cell pattern, as well:

Sub FreezeFormat2()
    Dim cell As Range

    For Each cell In Selection
        With cell
            .Interior.Pattern = .DisplayFormat.Interior.Pattern
            If .DisplayFormat.Interior.PatternColor <> 0 Then
                .Interior.PatternColor = .DisplayFormat.Interior.PatternColor
            End If

            If .DisplayFormat.Interior.Color <> vbWhite Then
                .Interior.Color = .DisplayFormat.Interior.Color
            End If
        End With
    Next cell
    Selection.FormatConditions.Delete
End Sub

In this iteration of the macro, the pattern color is only frozen if it isn't zero. This is for the same reason that the shading is compared to white—if it isn't done, then it makes the cells look like they have no gridlines.

Finally, you may want to freeze other formatting characteristics, such as font color and attributes. That is done in this iteration of the macro:

Sub FreezeFormat3()
    Dim cell As Range

    For Each cell In Selection
        With cell
            .Font.Color = .DisplayFormat.Font.Color
            .Font.Size = .DisplayFormat.Font.Size
            .Font.Bold = .DisplayFormat.Font.Bold
            .Font.Italic = .DisplayFormat.Font.Italic

            .Interior.Pattern = .DisplayFormat.Interior.Pattern
            If .DisplayFormat.Interior.PatternColor <> 0 Then
                .Interior.PatternColor = .DisplayFormat.Interior.PatternColor
            End If

            If .DisplayFormat.Interior.Color <> vbWhite Then
                .Interior.Color = .DisplayFormat.Interior.Color
            End If
        End With
    Next cell
    Selection.FormatConditions.Delete
End Sub

This version freezes font color, size, bold, and italic attributes. You could easily expand the macro to check and freeze other attributes, as well.

You should note that the above macros will work only if you are using Excel 2010 or later, because it appears that the .DisplayFormat object was added in that version of the program. If you are using an older version of Excel, then see the information provided in this ExcelTip:

https://tips.net/T13721

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 (10147) applies to Microsoft Excel 2010, 2013, 2016, 2019, 2021, 2024, and Excel in Microsoft 365.

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

Specifying the Number of Worksheets in a New Workbook

By default, a new Excel workbook contains three blank worksheets. You can (and should) configure Excel to whatever number ...

Discover More

Automatic Selection of Portrait or Landscape

Should you print in portrait or in landscape? The decision can greatly affect the way your printout looks. Wouldn't it be ...

Discover More

Finding Text at the End of a Table Cell

How do you use Find and Replace to locate information at the end of a table cell? Interestingly enough, there is no way ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 365 applications with VBA programming. Written in clear terms and understandable language, the book includes systematic tutorials and contains both intermediate and advanced content for experienced VB developers. Designed to be comprehensive, the book addresses not just one Office application, but the entire Office suite. Check out Mastering VBA for Microsoft Office 365 today!

More ExcelTips (ribbon)

Conditional Formats that Distinguish Blanks and Zeroes

Conditional formatting is a great tool. You may need to use this tool to tell the difference between cells that are empty ...

Discover More

Finding Duplicate Data Across Worksheets

Conditional formatting can be easily set up to check data on the current worksheet. If you want to check data on the ...

Discover More

Finding Cells that Use Conditional Formatting

Conditional Formatting is a great boon to effectively displaying the information in your worksheets. If you want to ...

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 five minus 0?

2025-04-13 10:14:41

J. Woolley

@Paul
FontStyle is not the same as a cell's Style.
FontStyle can be either Regular, Italic, Bold, or Bold Italic; therefore, the third macro's last two .Font statements
    .Font.Bold = .DisplayFormat.Font.Bold
    .Font.Italic = .DisplayFormat.Font.Italic
could be replaced by
    .Font.FontStyle = .DisplayFormat.Font.FontStyle


2025-04-12 21:22:52

Paul

In the third macro example, could the four .Font statements be replaced by the following one: .Font.FontStyle = .DisplayFormat.Font.FontStyle


2025-04-12 10:14:32

J. Woolley

This Tip references the Tip at https://tips.net/T13721
IMHO that Tip is worth reviewing even if you are using a modern version of Excel. For example, see my comment there.


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.