Frank Freese
asked on
Delete Conditional Formatting rules VBA
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.
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.
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
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.
ASKER
Here's my file. The company has restricted the link you gave me.
TryAgain.xlsm
TryAgain.xlsm
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
ASKER
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" ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Looks OK at this point - I'll work with it over the weekend and if I have a probleem I'll reconnect.
Thanks
Thanks
ASKER
Thank you kindly....
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
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
If you want to delete the conditional formatting on a specific worksheet.
Worksheets("CalAuotMiles").Cells.FormatConditions.Delete
ASKER
imnorie - I greatly appreciate your follow up here.
I really do!
I really do!