Conditional Formatting Clear From Entire WorkBOOK

tjscott0310

New Member
Joined
Dec 17, 2019
Messages
6
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
We run a real estate business and each transaction is a tab in a workbook. There are a few hundred built up over the years and the file is getting too large.

We would like to move older ones to an Archive Workbook for that year. It's painfully slow. I am pretty sure the conditional formatting is the culprit.

How can I clear the conditional formatting from the entire workbook in one fell swoop? Not just one sheet at a time?

I am using Excel 2019 as part of Office 365 Small Business

Thanks,
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Always test the code on a copy of your data file, not the data file itself.

Open the workbook, add the following module (Developer/Insert/Module), run it, save the file without the VBA script, i.e. save it as .xlsx file (I assume that the original file is in .xlsx format.)

If Developer is not on your menu bar, search the net to see how to add it to the menu bar.

VBA Code:
Sub delete_all_conditional_formatting()

'this script will delete all conditional formattings
'in the entire workbook

Dim ws As Worksheet

For Each ws In ThisWorkbook.Sheets

ws.Cells.FormatConditions.Delete

Next ws

End Sub
 
Upvote 0
Always test the code on a copy of your data file, not the data file itself.

Open the workbook, add the following module (Developer/Insert/Module), run it, save the file without the VBA script, i.e. save it as .xlsx file (I assume that the original file is in .xlsx format.)

If Developer is not on your menu bar, search the net to see how to add it to the menu bar.

VBA Code:
Sub delete_all_conditional_formatting()

'this script will delete all conditional formattings
'in the entire workbook

Dim ws As Worksheet

For Each ws In ThisWorkbook.Sheets

ws.Cells.FormatConditions.Delete

Next ws

End Sub

Thanks! I will try this in the next day or two and report back.
 
Upvote 0
Always test the code on a copy of your data file, not the data file itself.

Open the workbook, add the following module (Developer/Insert/Module), run it, save the file without the VBA script, i.e. save it as .xlsx file (I assume that the original file is in .xlsx format.)

If Developer is not on your menu bar, search the net to see how to add it to the menu bar.

VBA Code:
Sub delete_all_conditional_formatting()

'this script will delete all conditional formattings
'in the entire workbook

Dim ws As Worksheet

For Each ws In ThisWorkbook.Sheets

ws.Cells.FormatConditions.Delete

Next ws

End Sub
I tried this one one file, "Transaction Management (1).xlsx". Worked beautifully! Thank you.

When I went to the other file, I am getting a debug error. "Run-time error'13': Type mismatch. When I select "Debug", I get the screen shot below.

1577122380250.png
 
Upvote 0
Interesting! What is ws at that moment as seen in the watch or immediate window?
 
Upvote 0
Try
Rich (BB code):
For Each ws In ThisWorkbook.WorkSheets
You may have sheets that are not worksheets.
 
Upvote 0
Interesting! What is ws at that moment as seen in the watch or immediate window?

I'm sorry, I don't know what the watch or immediate window are. I never have used or learned about this part in Excel.

In the VBA Project window, if I scroll up, I see two charts. I have no idea where they are or why.

The solution below, "For Each ws In ThisWorkbook.Worksheets" work perfectly.

Thanks so much for you help! Saved me a few hours of work.

Merry Christmas!!
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,171
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top