Switch cell with color based on 3 different conditions

amaresh achar

Board Regular
Joined
Dec 9, 2016
Messages
108
Office Version
  1. 365
Platform
  1. Windows
Hi..

I need help with conditional formatting using formula:

I have the following values in my sheet:

E18: 287.2
F18: 289.2

If J18 is blank, then NO FILL ;
If J18 cell value is between cell values of E18 and F18, then fill J18 cell with LIGHT GREEN background color and DARK GREEN Text color
else fill J18 cell with LIGHT RED background color and DARK RED Text color

Thanks in advance.
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Does this satisfy your conditions?
Book1
EFGHIJ
18287.2289.2288
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
J18Expression=AND(J18<>"",J18>E18,J18<F18)textYES
J18Expression=AND(J18<>"",OR(J18<E18,J18>F18))textYES

Book1
EFGHIJ
18287.2289.2280
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
J18Expression=AND(J18<>"",J18>E18,J18<F18)textYES
J18Expression=AND(J18<>"",OR(J18<E18,J18>F18))textYES

Book1
EFGHIJ
18287.2289.2
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
J18Expression=AND(J18<>"",J18>E18,J18<F18)textYES
J18Expression=AND(J18<>"",OR(J18<E18,J18>F18))textYES
 
Upvote 0
Does this satisfy your conditions?
Book1
EFGHIJ
18287.2289.2288
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
J18Expression=AND(J18<>"",J18>E18,J18<F18)textYES
J18Expression=AND(J18<>"",OR(J18<E18,J18>F18))textYES

Book1
EFGHIJ
18287.2289.2280
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
J18Expression=AND(J18<>"",J18>E18,J18<F18)textYES
J18Expression=AND(J18<>"",OR(J18<E18,J18>F18))textYES

Book1
EFGHIJ
18287.2289.2
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
J18Expression=AND(J18<>"",J18>E18,J18<F18)textYES
J18Expression=AND(J18<>"",OR(J18<E18,J18>F18))textYES
Yes , this satisfies my condition.. is there a single formula to update in conditional formatiing..??
 
Upvote 0
Sorry... I didn't understand how to use the solution... which formula should I copy and how do I use it...?
 
Upvote 0
In your existing file, select cell J18.
From the Home menu, select Conditional Formatting/New Rule
Under Select a Rule Type - select Use a formula to determine which cells to format
Under Format values where this formula is true - copy the second formula and paste it into the box
Press the Format button, and set the format (fill & font) that you want for that condition, then OK to finish
Repeat with the second formula/format
Your Conditional formatting rule manager should look like this:
 

Attachments

  • CF .png
    CF .png
    33.4 KB · Views: 15
Upvote 0
In your existing file, select cell J18.
From the Home menu, select Conditional Formatting/New Rule
Under Select a Rule Type - select Use a formula to determine which cells to format
Under Format values where this formula is true - copy the second formula and paste it into the box
Press the Format button, and set the format (fill & font) that you want for that condition, then OK to finish
Repeat with the second formula/format
Your Conditional formatting rule manager should look like this:
Wow... works great... Thank you so much Sir...!!
 
Upvote 0
You're more than welcome Amaresh, and thanks for the feedback (y) :)
 
Upvote 0
You're more than welcome Amaresh, and thanks for the feedback (y) :)
Sir, can you please assist me to reproduce the formula using VBA for the range of cells as shown in the image...? and do the same for rest of the rows until the last row...?
req.JPG
 
Upvote 0
Firstly, I can't copy an image, and have no intention of recreating what your image shows for the purpose of providing a solution. Please provide a copy of your sheet using the XL2BB add-in, or better still share your file via Google Drive, Dropbox or similar file sharing platform.
Secondly, where you say the "range of cells" do you mean all the cells in columns J to S, from row 9 to the last row - all of which are referencing columns E & F?
Thirdly, why do you need to use VBA?
Finally, are those merged cells in columns E & F? If so, the task becomes a lot more difficult?
 
Upvote 0

Forum statistics

Threads
1,223,264
Messages
6,171,085
Members
452,378
Latest member
Hoodzy01

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