Multiple conditions in Excel conditional formatting - excel

I'm fairly new to Excel and so not very experienced, but I'm trying to get an entire row to highlight red based on 2 other cells, using conditional formatting. The requirements are for the corresponding M cell in the row to have the value 'N' and for the corresponding E cell to have a past date value '<*NOW'.
I've tried a formula based on an answer for multiple conditions:
=AND(M="(N)";E<*NOW)
A formula for formatting an entire row:
=INDIRECT("m"&ROW())="N",("e"&ROW())E<*NOW
And combining the two:
=AND=INDIRECT("m"&ROW())="N",=INDIRECT("e"&ROW())E<*NOW)
(ignore all the asterisks its the only way i could get the NOW to appear)
None of these are working, please help!

Assuming your data starts at row 2 then select all rows, e.g. 2 to 100 and then apply the condition for row 2, i.e. use this formula
=AND($M2="N",$E2<TODAY())
That will now apply to the whole range. The $ signs make it format the whole row

Related

Excel - How to highlight entire row if a specific cell is different from the cell above?

I am trying to apply conditional formatting in excel in which each first occurrence in a column has a highlight on the entire row. The desired result is as follows:
A
B
2
2
8
Highlight this entire row
5
Highlight this entire row
5
7
Highlight this entire row
I currently have the formula "A3<>A2", but that highlight the last occurrence instead of the first. I don't know how to apply the highlight to all cells on the same row.
UPDATE: Apparently excel behaves differently for text and numeric values. My data looks like this:
A
B
Apple
Apple
Banana
Highlight this entire row
Kiwi
Highlight this entire row
Kiwi
Apple
Highlight this entire row
Conditional Formatting - Entire Row For First Occurrence in Column
The issue you are facing is that you have selected e.g. the range 2:10 (focus on 2) and e.g. you are applying the corrected ($) formula =$A3<>$A2 which does what is expected: it highlights the last occurrence in a group i.e. if the value of the next row (3) is different than the value of the current row (2) then highlight row 2.
To highlight the first occurrence in a group, you need =$A2<>$A1 as correctly posted by user11222393 since the first row you selected is row 2 i.e. if the value of the previous row (1) is different than the value of the current row (2) then highlight row 2.
My solution will work similarly if the data is sorted. It will not highlight the first row of repeating groups though, as illustrated in the screenshot below.
You will notice the difference between the solutions best by sorting the data in another column. Mine should have fewer highlighted rows.
Usage
Select the entire rows of the range and goto Home -> Conditional Formatting -> New Rule -> Use formula... (you know the drill) and e.g. use
=COUNTIF($A$2:$A2,$A2)=1
for the first row being row 2.
=$A2<>$A1
Take a look at $ symbols. If you don't use it it will highlight only 1 cell, because it will compare A2 to A1, B2 to B1 and so on.
Result:

Conditional formatting based off the previous X number of cells

I am trying to setup conditional formatting so that the formatting takes effect if the previous 4 cells in a column are blank. I need the range inside the conditional formatting formula to move as it is applied to cells below it, for example:
If I am tracking sales by store, if there is a 4 week period where a certain store doesn't record any sales I want those 4 weeks to automatically highlight.
My current formula is to select cells B5:B11, enter the formula =SUM(B2:B5)=0 to trigger the cell highlighting.
My problem is that when I look at cell B6 the range it looks for to be blank is still B2:B5 and I need it to be B3:B6.
Is there a way to set this up so that the range will change as it moves down a column?
This one has gotten me thinking a bit, and here is my solution for it.
My solution needs to use four conditional formattings, i.e. set up four conditional formattings in each cell, and then use format painter to apply the conditional format to all the cells.
Suppose your week table is in range A1:D20, and suppose you want to highlight cells if there are at least (not only) four consecutive blank cells.
Highlight cell B2, and then set up conditional formatting using the following four formulas:
=SUM(OFFSET($B2,0,0,4,1))=0
=SUM(OFFSET($B2,-1,0,4,1))=0
=SUM(OFFSET($B2,-2,0,4,1))=0
=SUM(OFFSET($B2,-3,0,4,1))=0
Then should have something similar to the following when examing the conditional formatting window:
Lastly, highlight cell B2, use the Format Painter function under Home tab and then apply the format to the rest of the cells in the week table. Then you should have something similar to the following:
It is easy to find the first blank cell of four consecutive blank cells, but it is difficult to identify the second, third and fourth blank cells using one formula. The workaround uses four different formulas to identify each of the four blank cells (I hope this makes sense). Please note the following is only looking at Column B of my example, not all columns:
Not pretty, but it works. This will highlight all occasions where the store has at least 4 weeks of consecutive donuts.
Columns B:D = Original Data
Columns E:G = Helper Set 1
Columns H:J = Helper Set 2
There's probably a way to get just one helper set, but this works and was easy to validate. First I added 3 empty rows above week 1.
In cells E4, E5 and E6 place a 0. You don't have to, you could also leave these blank.
Cell E5 formula, which is counting the number of consecutive blanks:
=IF(ISBLANK(B5),E4+1,0)
Drag it over to column G and drag it down.
Cell H5 formula, which is looking at 4 weeks later to see if there were consecutive blanks found in helper set 1:
=IF(E8>=4,"Yes","No")
Drag it over to column J and drag it down. Also, in the row above it, repeat week 1 values.
Lastly, select your original data range (B5:D14) and create this conditional formatting formula:
=(OR(H5="Yes",H4="Yes",H3="Yes",H2="Yes"))
Once you're satisfied, you can hide rows 2:4 and can also hide your helper columns.
Apply the following condition to each respective ranges:
Range: B2:D2:
=SUM(B2:B5)=0
Range: B3:D3:
=OR(SUM(B2:B5)=0, SUM(B3:B6)=0)
Range: B4:D4:
=OR(SUM(B2:B5)=0, SUM(B3:B6)=0, SUM(B4:B7)=0)
Range: B4:D8:
=OR(SUM(B2:B5)=0, SUM(B3:B6)=0, SUM(B4:B7)=0, SUM(B5:B8)=0)
Result with sample data:

How to highlight 1st, 2nd and 3rd highest from two column

I tried by selecting range then conditional formatting then cell value equal to then =large($C:$E,1) THEN fill golden color for 1st highest value. This formula applies to entire columns. I need help with applying formula within range i.e from 31 t0 41. I have values in column C i.e c31:c41 and column E i.e E31:E41 in percentage . I want golden color for 1st ,silver for 2nd and yellow for 3rd highest of two columns. Column D has names so column D can not be selected.
SAMPLE EXCEL FILE
sample data
C D E
2.54% vinu 5.69%
119.90% anand 157.34%
49.32% tanaji 7.39%
82.28% umesh 121.21%
-21.66% chandu 94.10%
-60.45% rajan -25.71%
-20.12% mule 37.02%
-16.05% jafgtap 31.085%
-3.50% kunal 282.62%
-3.27% ramesh 14.58%
-8.12% rajesh 5.86%
Select the cells C31:C41 and insert a new formatting rule using a formula. This is the formula if your data starts in row 31 and the active cell is C31.
=C31=LARGE($C$31:$E$41,1)
Note the placement of the $ signs. It is important. Format this to be gold, then
create two more rules with 2 and 3 as the last parameter for silver and bronze.
If the currently selected cell is on a different row than row 31, use the respective row number. My screenshot starts with row 1.
Select the cells in the worksheet, click the Format Painter on the Home ribbon and select cell E1 to apply the same rule to the cells in column E. In the screenshot I changed your sample numbers so column C has the third highest value.
Edit after comment:
If you explicitly want to exclude the values in column D, you can perform the Large() function on a limited list of ranges like this:
=LARGE(($C$31:$C$41,$E$31:$E$41),1)
Unfortunately, Conditional Formatting rules will not accept formulas with that level of complexity. The solution is to create three defined names with these formulas:
Gold =LARGE((Sheet11!$C$31:$C$41,Sheet11!$E$31:$E$41),1)
Silver =LARGE((Sheet11!$C$31:$C$41,Sheet11!$E$31:$E$41),2)
Bronze =LARGE((Sheet11!$C$31:$C$41,Sheet11!$E$31:$E$41),3)
Then you can use three conditional formatting rules that compare the value in the range with the values of the defined names Gold, Silver and Bronze
This post has been quiet for a while, but maybe you can help me.
I have a large file with criteria across the top, labels on the left and scores in the middle. I've correctly modified the formula above for row based eval.
=B2=LARGE($B2:$X2,1) and =B2=LARGE($B2:$X2,2) and =B2=LARGE($B2:$X2,3)
I've noticed that if there are joint second largest values, then the third one doesn't work, and but the 4th one does work. It's not a major pain.
What I want to do now is apply the conditional formatting for the second row to all other rows (about 40). I can't see a way to copy the conditional formatting and I don't really want to enter the three of them 40 times.
Any ideas?
Thanks

Conditional formatting on visible range?

I have a table with times of actions and I want to highlight rows that are more than 20-ish minutes more than the one above.
The actual number of minutes is less important.
For that I use conditional formatting with the formula:
=F3-F2>0,01766
So far so good.
But now if I apply filter on the table the the formula does not work anymore because it looks at the hidden rows.
Only the first highlight is made by the conditional formatting the other two are done by me.
Is it possible to get conditional formatting to look at the visible rows only?
I was able to come up with a solution only by using a special columns for the filtered index. In my example, i am filtering the data by '1', So i will add '1' in Column L. If you have multiple filters, you can add in the next rows in col L.
Col H checks if cell in Col E exists in the filters list
Col I finds the last row that is not filtered. The formula has to be entered as an Array Formula i.e. enter the formula and press Ctrl Shift Enter
Col J checks if the difference between cells in Col F for the current row and the last not filtered row is between 20 and 21 minutes. Conditional formatting is applied for this cell being true
Below image without applying any filter
After adding '1' as filter
Filtered rows hidden
Formula
Here is a Google Sheet
Note that SUBTOTAL() has options for ignoring hidden rows: this gives you a way to create a formula-based helper column for determining whether or not a row is filtered out....
Note Col C is an Array formula
After filtering for "A" only:
This way you can filter on multiple columns if required.

How to do a Conditional Formatting with hh:mm:ss format on Excel

I have two different columns. Each one contains timestamps in hh:mm:ss format, and I want to do a between comparition and check if the Value Colum 2 is between Value Column 1 Row 1 and Value Column 1 Row 2, and then, paint the cell in green, or in red if the condition is not satisfied.
Here my columns:
Column 1 Column 2
16:06:13 16:07:34
16:06:41 16:08:42
16:08:39 16:09:49
16:09:47 16:11:02
16:10:53 16:12:10
16:12:08 16:13:40
16:13:39 16:14:48
16:14:47 16:16:04
16:18:06 16:18:06
I applied a Conditional Formatting -> HighLight Cell Rules -> Between
then from Column 2 Row 1, I selected the first value from Column 1 Row 1 and the next value from Column 1 Row 2, but nothing happens.
Anyone can help me?
Thanks!!
Following the process you did:
Highlight the values in Column 2
Conditional Formatting -> Highlight Cell Rules -> Between
Select the first value from Column 1 Row 1 then delete the dollar signs
Select the second value from Column 1 row 2 then delete the dollar signs
Note: I see that there is sometimes a glitch in some versions of Excel which replaces your cells with cells at the bottom of the spreadsheet. I find if I just repeat the steps another time, it fixes the issue.
Two rules with two different formulas:
1st:
=MEDIAN(B1,A1,A2)=B1
And format it to Green
2nd:
=MEDIAN(B1,A1,A2)<>B1
Another alternative method:
Highlight the values in column 2.
Conditional Formatting -> New Rule
Select "Use a Formula to determine which cells to format"
Under "Format values where this formula is true", input: "=AND(B1 >= A1,B1 <= A2)"
Select "Format..." and choose the formatting you want
Click OK
Note that this method, vs. the other one I gave you, treats the last cell differently (since there's no value after it). The first one will highlight it, this one will not.
Note: With both methods, I see that there is sometimes a glitch where Excel replaces your cells (A1, A2, and B1 in this case) with cells at the bottom of the spreadsheet. I find if I just repeat the steps another time, it fixes the issue.
If you wish to stick with in-between you can
The data I have in those two fields is
=INDIRECT(ADDRESS(ROW(),COLUMN()-1))
=INDIRECT(ADDRESS(ROW()+1,COLUMN()-1))
You will still need two of these as said in other answers.

Resources