VBA + Conditional Formatting

Nanogirl21

Active Member
Joined
Nov 19, 2013
Messages
331
Office Version
  1. 365
Platform
  1. Windows
Can someone please help with a VBA to do the following


(1) Clear conditional formatting from worksheet titled Tracking


(2) Apply conditional formatting for all rows in column O with the below rules
a. change cell background to LIGHT GREEN if formula is true

Code:
 =OR(T1="APPLE", T1="BANANA", T1="APPLE / HOLD", T1="BANANA / HOLD")

b. change cell background to ORANGE if formula is true

Code:
 =SEARCH("HOLD",T1)
c. change cell background to RED if formula is true

Code:
 =AND(OR($L1="GRAPES",$L1="CUCUMBER",$L1="TOMATO"),$O1<10)

Notes
-I’d like to use conditional formatting because I need the cell colors to change when making updates throughout the day.
-I don’t want to apply the rules manually because there are a lot and they would need to be changed often. It’s easier to create a VBA code for each set of rules I’d like to apply.
-If there is any way to make the formulas I used simpler I am all for it!
-T1 and L1 would change to T2, T3, T4, T5 and L2, L3, L4, L5 ect since the rules will be applied to the entire column. I don’t have an exact amount of rows because the data is constantly growing.
- It would be great if I could add a HEX code or RGB for the color i'd like the cell background to.


Thank you.
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Hello Nanogirl21,

Personally, I stay away from using VBA to setup Data Validation because of the coding needed to do it. Also, users often prefer to keep workbooks macro free whenever possible. Data validation can be accomplished in other ways when using VBA but it really depends largely on your data, layout, and needs.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
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