简体   繁体   中英

Excel VBA - macro to disable & enable conditional cell format

I'm looking for a macro that will disable the conditional cell format of several specific cells.

Essentially, I have used the conditional cell format to create a merged field of 9 cells (L2:N4) that will turn red and display "ERROR" in case some entered data appears to be wrong. However, I want to give the user the ability to have a button that she can click in order to manually disable this format and display the standard "PASS" in green. This should be achieved through a CommandButton; upon click, I would like to add a confirmation, ie "Are you sure you want to manually override?" followed with a yes/no choice.

I then would like the CommandButton to turn into another commandbutton that can undo this change for this particular sheet, even if some other actions were taken in the meanwhile that should not be changed.

As I am totally new to VBA and only know some basics, I have no idea how to start this... can you please give me a hand with sorting this out?

Thank you very much indeed for your help, that's much appreciated.

Instead of a VBA/CommandButton solution, you could also just have a checkbox, linked to a cell!

All you need to do is to adjust the conditional format rules to be dependent on this cell. To do this you have to provide a custom formula in the conditional highlighting settings, eg =AND(YourCell,SomeErrorCheck)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM