Solved

Delete Conditional Formatting rules VBA

Posted on 2013-10-25
11
1,631 Views
Last Modified: 2013-10-25
Folks,
I've looked for VBA code to delete any conditional formatting rules in a worksheet. What I've seen is a little confusing.
The reason is I have some worksheets that people can practice with that have conditional formatting. If the user wants to try again then they'd click on the "Try Again" command button and if any conditional formatting rules were part of the exercise those would be deleted.
0
Comment
Question by:Frank Freese
  • 5
  • 4
  • 2
11 Comments
 
LVL 10

Expert Comment

by:Anthony Berenguel
ID: 39600805
Take a look at this. If you need to remove all conditional formatting from every sheet in the workbook you'll need to make some adjustments, but we can help you with that. http://mydailymicrosoft.blogspot.com/2011/04/excel-vba-remove-all-conditional.html
0
 
LVL 10

Expert Comment

by:Anthony Berenguel
ID: 39600809
Also, if you attach a practice copy of your workbook I could implement the code for you and comment it so that you can learn from it.
0
 

Author Comment

by:Frank Freese
ID: 39600851
Here's my file. The company has restricted the link you gave me.
TryAgain.xlsm
0
 
LVL 33

Expert Comment

by:Norie
ID: 39600856
This will remove all the conditional formatting in all sheets.
Dim ws As Worksheet

    For Each ws In ThisWorkbook.Worksheets
        ws.Cells.FormatConditions.Delete
    Next ws

Open in new window

0
 

Author Comment

by:Frank Freese
ID: 39600902
I only need it for the worksheet conditional formatting applies to and not all sheets. Can I replace ".Worksheets" with the name of the worksheet, ".CalAutoMiles"? or .Worksheets."CalAutoMiles"?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 10

Accepted Solution

by:
Anthony Berenguel earned 500 total points
ID: 39600910
This should do the trick. I did some quick testing but it could use a thorough test. Let me know if you have any questions.
TryAgain.xlsm
0
 

Author Comment

by:Frank Freese
ID: 39600922
Looks OK at this point - I'll work with it over the weekend and if I have a probleem I'll reconnect.
Thanks
0
 

Author Closing Comment

by:Frank Freese
ID: 39600935
Thank you kindly....
0
 
LVL 10

Expert Comment

by:Anthony Berenguel
ID: 39600943
Sounds good.

Note: Right now it's looking through all the cells in the range of A1:G12. If you know that there will only be VBAConditionalFormatting in column G you can change the A1:G12 to G1:G12 in the code. Or you can change it as necessary.

One more thing, it's only looking for cells that have a red fill with white text. If there are other combinations it needs to look for you'll have to add them or let me know and I can help.

Have a good weekend.

ab
0
 
LVL 33

Expert Comment

by:Norie
ID: 39600956
If you want to delete the conditional formatting on a specific worksheet.
Worksheets("CalAuotMiles").Cells.FormatConditions.Delete

Open in new window

0
 

Author Comment

by:Frank Freese
ID: 39600990
imnorie - I greatly appreciate your follow up here.
I really do!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
location range 4 22
Compile Error 7 41
sql server query from excel 3 57
Excel - Transposing columns/rows (sort of!) 7 14
Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now