Code to change cell color based on value

UFGATORS

Board Regular
Joined
Nov 28, 2008
Messages
136
Office Version
  1. 365
I currently have a spreadsheet that I use conditional formating to change a cells color based on the value entered in the cell. My problem is that sometimes the conditional formating does not work properly. I'm assuming a code could be developed to do this task. If someone could help with this I would appreciate it. Following are the particulars
The range that the codes are entered in is G3:AK252
I would like for the cell to turn red for thefollowing codes (AL+, SAL,SSL,MC,DCD,DCS, and SL), Blue for codes (AL and BH) and Green for codes (EAL, EAL/AL,EAL/SSL,EAL/BH,ESL,ESL/BH,ESL/MC, ESL/AL, NA, NA/SSL, NA/DC, A/DCD, and ASC).

Thanks, Steve
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Select cells G3:AK252

Condition 1
Formula is =ISNUMBER(SEARCH("|" & TRIM(G3) & "|", "|AL+|SAL|SSL|MC|DCD|DCS|SL|"))
Format Red

Condition 2
Formula is =OR(TRIM(G3)="AL",TRIM(G3)="BH")
Format Blue

Condition 3
Formula is =ISNUMBER(SEARCH("|" & TRIM(G3) & "|", "|EAL| EAL/AL|EAL/SSL|EAL/BH|ESL|ESL/BH|ESL/MC|ESL/AL|NA|NA/SSL|NA/DC|A/DCD|ASC|"))
Format Green
 
Last edited:
Upvote 0
Sorry for my ignorance, but how do I enter the code. I tried pasting it into a module in VBA and that did not work.
 
Upvote 0
Got it, they work fine. If it is not to much to ask, could you explain what the different elements of the formula are doing or asking. I would really like to learn how do to this. Thanks
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,286
Members
452,902
Latest member
Knuddeluff

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