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.
 
"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."

Sorry Sir. I was facing some issues with google drive page, so could not upload/ share the link... so.. here is the link:


"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?" -- Yes Sir.. you are exactly right... and similaraly for subsequent rows..

"Thirdly, why do you need to use VBA?"
I need to add some VBA script in the file for some other tasks like color, font, cell protection, cell merge etc. So I thought it would be better to have all the tasks to be scripted in a single program. But if it can be done with formula even then its great.

"Finally, are those merged cells in columns E & F? If so, the task becomes a lot more difficult?"
Yes... I see why so many excel experts don't recommend merging of cells... But Sir... nothing to worry about... it's just for aesthetics... and good report visibility on the display screen.. And I checked the validity of formulas.. and it works even with merged cell.. (If correct cell refence is given in the formula i.e Exact reference as given in the name box when I selected the merged cell)
 
Upvote 0

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Thank you Amaresh for your detailed response. This will require only minor changes to the existing CF: use absolute references to columns E & F, and adjust the Apply to range. Change the Apply to range from $J$9 to $J$9:$S$508. Details below, and link to the file with the changes applied here Blank Template Mr. Excel.xlsm

Blank Template Mr. Excel.xlsm
EFGHIJKLMNOPQRS
8Min (Ref)Max (Ref)Inspection Gauge / Tool / MethodAssy CriticalInspector12345678910
9287.2289.2Tool-A-1NSupplier289.2
10IQC180
11Min-A-2Max-A-2Tool-A-2YSupplier
12IQC
13Min-A-3Max-A-3Tool-A-3NSupplier
14IQC
15Min-A-4Max-A-4Tool-A-4YSupplier
16IQC
17Min-A-5Max-A-5Tool-A-5NSupplier
18IQC
19Min-A-6Max-A-6Tool-A-6YSupplier
20IQC
21Min-A-7Max-A-7Tool-A-7NSupplier
22IQC
23Min-A-8Max-A-8Tool-A-8Y
24
25Min-A-9Max-A-9Tool-A-9N
26
Report
Cells with Conditional Formatting
CellConditionCell FormatStop If True
J9:S508Expression=AND(J9<>"",OR(J9<$E9,J9>$F9))textNO
J9:S508Expression=AND(J9<>"",J9>=$E9,J9<=$F9)textNO
H8:I8Cell Value="Y"textNO
H8:I8Cell Value="N"textNO
 
Upvote 0
Solution
Sir, Thank you so much for the response... but it says "Sorry, the file you have requested does not exist."

I guess, the download link is expired.. Can you please re-upload the file...??
 
Upvote 0
Thank you so so much Sir..!!! that works great...!!! (This is better, quick and dynamic compared to my idea of including the task in VBA)
 
Upvote 0
I tried copying the same formula for larger range Sir... but I seem to have done something wrong... every alternate row (IQC) is not formatting as per rule... Can you please help me out here...!?


FORMULA.JPG
 
Upvote 0
I tried copying the same formula for larger range Sir... but I seem to have done something wrong... every alternate row (IQC) is not formatting as per rule... Can you please help me out here...!?


View attachment 95042
The file with the link in post #14 had the correct formulas in the entire range down to row 508. Did you try putting some values in the linked file to test the CF, rather than trying to copy the format yourself?
 
Upvote 0
The file with the link in post #14 had the correct formulas in the entire range down to row 508. Did you try putting some values in the linked file to test the CF, rather than trying to copy the format yourself?
Sir...In the previous file... I wanted the Conditional formatting from J0 to S508...
Later I realised that I need to have more rows... so increased the selection range upto S1034... And now the range is starting from J21...
So I wanted to tweak the formula accordingly.. but formula could not be edited...
So I typed same formula just replaced row9 with row25...
 
Upvote 0
Sir...In the previous file... I wanted the Conditional formatting from J0 to S508...
Later I realised that I need to have more rows... so increased the selection range upto S1034... And now the range is starting from J21...
So I wanted to tweak the formula accordingly.. but formula could not be edited...
So I typed same formula just replaced row9 with row25...
So I typed same formula and just replaced row9 with row21
 
Upvote 0

Forum statistics

Threads
1,215,168
Messages
6,123,408
Members
449,098
Latest member
ArturS75

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