Conditional formatting: highlighting rows based on condition - excel

Suppose I have the following table:
Date Value
5/27/2017 5
6/10/2017 7
6/24/2017 8
7/8/2017 5
7/22/2017 10
I want to highlight the most recent row, meaning the row with the date closest to today. I know I need to use Excel's conditional formatting capability, so I created the indicator column _inRange, which derives from this function:
=IF(AND(A2 <= TODAY()), TODAY() < A3), 1, 0)
The new table:
Date Value _inRange
5/27/2017 5 0
6/10/2017 7 0
6/24/2017 8 1
7/8/2017 5 0
7/22/2017 10 0
So, where _inRange equals 1, the row should be highlighted. I can highlight the _inRange cell properly, but am having difficulties highlighting the entire row. Can anyone provide direction here? I looked at this Exceljet post but obviously was left with questions.
Edit:
I changed _inRange to boolean (I don't think boolean TRUE/FALSE versus 1-0 is the main issue, though) and am still having issues:
Date Value _inRange
5/27/2017 5 FALSE
6/10/2017 7 FALSE
6/24/2017 8 TRUE
7/8/2017 5 FALSE
7/22/2017 10 FALSE
Here's a picture of my conditional formatting window:
I first select the entire table, then go to Home > Conditional Formatting > Highlight Cells Rules > Equal To and set the value as TRUE. Then I change the column as E. Trauger suggested but nothing changes.

In the Conditional Formatting Rules Manager (Home->Conditional Formatting->Manage Rules...) make sure your conditional format is correct in the "Rule" Column and then make sure the "Applies to" column is also correct. I suspect this is your problem.
Try changing the rule to: =$C2=1
And change range of application to: =$A$2:$C$10 (or whatever the C column goes to)

The way I would do this would be to use the conditional formatting on the entire row, where for any cell in that row, it is going to check the _inRange of that row. Something like this, after New Formatting Rule --> Use a Formula to Determine which cells to format:
=INDEX(C:C,ROW())=1
Replace C:C with whatever column _inRange is in, and apply the formatting to the entire table.

Related

Excel Conditional Formatting Unexpected Result

The conditional format rule is set as an equation doesn't behave as I expect (highlight only values that are =1 in Column M corresponding to the current row). Instead they are seemingly randomly colored.
My code is as follows:
IF($M5=1,TRUE,FALSE)
where true results in the color green, false default formatting. This formatting is copied along a column, e.g. I also expect the value M$5 to correspond with the row in the cell with formatting in column M.
I observed that the color changes sometimes when Mrow=1, sometimes not.It appears uncorrelated with the row value. See below.
Item M-column Color
#1. 1 none
#2 0.48 green
#3. 0.0. green
#4 1. green
Any suggestions to understand what to try next to fix the probelm?
Thanks
Your formula is offsetting the row by 5, either use =$M1=1 or use the conditional formatting dropdown options to select highlight cells -> Equal to...
Based on the data provided it looks like your raw data has a 1 in rows 8,9,10, which is why it formatted the cells five rows above as green.
Also, you don't need to wrap your logical test in an IF() statement, it will return TRUE or FALSE either way.

How to mark column value found False as zero | Excel | Conditional formatting |

I have a scenario where i want to mark the value as zero if found to be FALSE
Below is my table of data
in above image if you see the column 4 => cell C4 as one 'FALSE' value and correspond to that B4 cell as Blank value
i need to set that B4 value to zero.
Note : need to search the column 4 to find false keyword and correspond to that the B column cell value is blank it need to be set as numeric value Zero
how to do it using conditional formatting
my below code
=ISNUMBER(C4='FALSE' then B4 set to zero)
My first post, so be gentle please.
I am pretty sure that you could do that with conditional formatting, but I can think of simpler options. Is it required that you use conditional formatting, or do you need to get it done?
You could use Find & Replace functionality. Just select the range - which will be the whole column or part of it in your case, click Ctrl+H, go to the second tab (find and replace), leave the find field blank and write number 0 in replace field, then hit replace button until you feel all is done.
You could do that with a function as well, but I think that should do the job. I will check this post tomorrow as well, so feel free to comment.
I am not sure if conditional formatting can set a value. Conditional formatting as the name suggest is used to set the "Formatting".
To address your need, here is what I would do:-
Create a new column called "RollNumber" and rename the old one as "Old RollNumber"
In the new column, i.e. cell B2 type the formula =IF(ISNUMBER(C2),C2,0)
Copy the formula through to the bottom of the table (now this will apply to all)
Before hiding column C
Hide column C this will hide the "Old RollNumber" column
After hiding the column
Hope that helps.

Color coding results from COUNTIFS plus OR function

I may be going about this the wrong way so if someone has an alternative method let me know.
I have two columns of values. Column A has values spanning -5 to 5 and column B has values from 1 to zero. My goal is to indicate which rows have both a Column A value of either <-1 or >1 and a Column B value <0.05. My current Excel function is:
=COUNTIFS(A1,">1",B1,"<0.05")+COUNTIFS(A1,"<-1",B1,"<0.05")
This works in that it returns a 1 if either of the criteria are met however it does not tell me which criteria was met so I was wondering if there was a way to color code the results so that if the first was met (>1 and <0.05) the cell would be green and if the second was met (<-1 and <0.05) it would be red.
Use conditional formatting.
You can put several rules there. In your case they would be (assuming that values are in cells A1:B10):
Rule 1: =AND($A1>1;$B2<0.05) , Color: Green , Range: =$A$1:$B$10
Rule 2: =AND($A1<-1;$B2<0.05) , Color: Red , Range: =$A$1:$B$10
These rules will color whole row, i. e. cells in column A as well as in column B.
Please, note, that, in order to make formula work correctly, column address is locked with $ (if it would be absent, rule 1 formula for cell A1 would work like =AND(A1>1;B2<0.05) , and for column B1 - like =AND(B1>1;C2<0.05), which is not what we need)
P. S. In complex situations when there are overlapping rules (which is not your case), you can make set of conditional formatting rules work correctly by adjusting their order, or by setting "[ ] Stop If True" checkbox.

Excel, Creating 3 conditions for Conditional Formating

My situation is this. I have an excel sheet that contains 6 columns I need to compare G:L,
in these columns each cell contains a Dollar value or are Blank.
I need to figure out how I can return into column M 3 distinct values
ALL cells within a row Match
The row Contains Blanks
NOT all rows Match
I used =NOT(STDEV(G3:L3))
which gave me True / False / #DIV/0! but when I tried conditional formatting with 3 Rules
Formula:=$M4:$M2693=TRUE (background GREEN) Applies to =$A$4:$L$2693
Formula:=$M4:$M2693=FALSE (background RED) Applies to =$A$4:$L$2693
Formula:=$M4:$M2693=#DIV/0! (background YELLOW) Applies to =$A$4:$L$2693
I would get no Yellow rows, DIV/0 Rows would be the colour of what ever row was above them.
I figure if I can have column M return 3 distinct values be they A, B C 1,2,3 or anything that isn't #DIV/0! I should be able to make conditional formatting work
BONUS is if I can have it return 4 values the 4th value indicating ALL rows are Blank, since that would be heading rows but it doesn't really matter as I can manual edit those 40ish rows.
* EDIT *
Tom Lead me in the right direction, but to get the formatting perfectly I did have to make a few modifications
=COUNTBLANK($H$3:$L$3)=5 (No Formatting)
=STDEV($H3:$L3)>0 (Red)
=STDEV($H3:$L3)=0 (Green)
=COUNTBLANK($H3:$L3)<5 (Yellow)
Then it worked fantastically, So if you're reading this because you have the same problem tweeking the order can have a lot to do with your conditional formatting
OK I have four rules to be fired in this order:-
=COUNT($G4:$L4)=0 - no format set
=COUNT($G4:$L4)<6 - yellow
=STDEV($G4:$L4)>0 - red
=STDEV($G4:$L4)=0 - green
After entering them in Conditional Formatting I used Manage Rules, setting the rules in this order and ticking the stop on error box so they behaved properly.
It's true that STDEV will give a #DIV/0! error if it has less than two numbers to work on, but that doesn't matter because it will be covered by the 'yellow' case and even if it wasn't it would just mean that it wouldn't fire.
A formula to give values for a helper column would look like this:-
=IF(COUNT($G4:$L4)=0,1,(IF(COUNT($G4:$L4)<6,2,(IF(STDEV($G4:$L4)>0,3,4)))))

Excel Conditional Formatting, Referencing 2 cells to the Right with conditions

I have a list of students who are between the ages of 3 and 5. lets say column A has the code, Column D has the childs age & Column F has their age group (3-5) If their age exceeds the age group then the Cell in column A will highlight Red. I am just not sure how to write this code correctly, all of the combinations i have tried come up with an error or just don't do anything.
IF(OFFSET(INDIRECT(ADDRESS(ROW(),COLUMN())),0,7)="3-5" & (OFFSET(INDIRECT(ADDRESS(ROW(),COLUMN())),0,4)>5 {THEN FILL CELL RED} {ELSE NO FILL}
In the first part of the statement you are checking whether the cell 7 columns across = "3-5". You don't need to use offset for this, you can just reference the cell 7 across directly.
So if you're applying the conditional formatting to A1 that part of the formula would just be =IF(H1="3-5",{then},{else}).
If you just want TRUE or FALSE as the answer you don't need the IF statement, so this shortens to: =H1="3-5",
If you're applying the conditional formatting to a range instead of just an individual cell, say A1:B10, then you write the formula for the cell in the top left of the that range. So for A1:B10 you would still you the same formulae as above.
For the second part of the statement, using the same logic as above, you get: =E1>5
To check both statements together you need to wrap them in the =AND() function, giving you this as the final formula for your conditional formatting:
=AND(H1="3-5",E1>5)
By using the AND function I can achieve the desired result without cell references moving if a cell is relocated.
=AND(OFFSET(INDIRECT(ADDRESS(ROW(),COLUMN())),0,7)="3-5yo",OFFSET(INDIRECT(ADDRESS(ROW(),COLUMN())),0,4)>5)

Resources