I would like the following result:
Number of cells (here 3) highlighted below the cell contains TRUE
Is there any solution for this?
There is no VBA needed:
Go to cell D4 and select it (otherwise the provided formula will not work).
Add a conditional formatting rule (formula) and add this as formula:
=OR(IFERROR(D1=TRUE,FALSE),IFERROR(D2=TRUE,FALSE),IFERROR(D3=TRUE,FALSE),IFERROR(D4=TRUE,FALSE))
Save the rule and copy format of D4 into your desired range. The result will be like below:
Note that WAHR means TRUE (sorry for german screenshot)
Related
i have two columns (Start Date, End Date) and i want a code that changes the color of both their cells to red if the start date and end date contained any date located in another sheet
I tried using conditional formatting using this rule: =AND(C2<=Holidays!$A$2:$A$15,D2>=Holidays!$A$2:$A$15)
Tested out the below formula for myself and think it should work! Effectively rather than a simple AND statement, since we're comparing against an array of values rather than single cells, we need to use some handy array formulas. This post gives a good breakdown of what's going on under the hood: https://exceljet.net/formula/index-and-match-with-multiple-criteria
Apply this formula in conditional formatting, assuming the range you're formatting starts at C2.
=SUM((Holidays!$A$2:$A$15>$C2)*(Holidays!$A$2:$A$15<$D2)) > 0
Also, wanted to call out the absolute references specified for columns. I've specified **$**C2 and **$**D2 in my formula, which means that no matter which cell in your conditional formatted range it'll evaluate off the values in column C and D. In your current formula, cell C2, would evaluate on C2 and D2, but cell D2 would then evaluate off D2 and E2. This'd be why when you tried the manual formatting only the start date cells (column C) were formatting correctly.
Hope this helps!
Update::
If you had a table format like in the attached screenshot, you would apply the conditional formatting formula:
=SUM((Holidays!$A$2:$A$15>$C2)*(Holidays!$A$2:$A$15< $D2)) > 0
To cell range $C$2 : $D$3
If you're changing the cell range (say you wanted to apply to $C$10 : $D$14), you'd just change the $C2 and $D2 in the formula --> $C10 and $D10.
I need a formula for conditional formatting. It's extremely simple, or so I thought. If cell R4 has any number, such as 1935001011, cell E4 should be highlighted yellow. If there is no value, there should be no highlight. I need to do this for the entire range of cells in column E.
Try selecting ColumnE and applying a CF formula rule to it of:
=ISNUMBER(R1)
The formula would simply be:
=ISNUMBER($R4)
And then the Applies To range (change the rows as needed):
=$E$4:$E$1000
And just choose the conditional formatting options you want.
Try:
Select the range you want
Home - Styles - Conditional formatting - Highlighting Cells Rules - More Rules - Use formula....
Copy =$R4<>""
Format - Fill - Select color Apply & Ok!
I have written a formula:
=IF(len(d2)>0,IF(d2=0,true,false),IF(len(e2)>0,IF(e2=0,true,false),false))
I want to strike through entire row if the formula returns true. But it is not working. Annoying facts are:
If I place this formula into a cell, it shows correct true or false value.
If I apply this formula on entire row, only A2 and B2 cells are formatted.
To test whether there is come conflict with other formatting rules, I just removed the formula, and just wrote "true" in the custom formula column. And the entire row was formatted. I pasted formula into a cell and it was also returning true. How does the fomula which is returning true in the cell is returning false in conditional formatting?
I applied the formula to cells which have no other conditional formatting rules. The formula didn't work. So how the formula was working for A2 and B2 cells?
I tried using values other than true/false. As usually, it worked perfectly in cell, but not in conditional formatting.
It is not working even on fresh spreadsheet.
Please check it yourself. To get "True" value from the formula, enter 0 in d2 and e2 and see yourself that conditional formatting is not respecting it.
Thanks in advance for giving time to read the question.
The reason that the formula is only working for cells A2 and B2 is because D2 and E2 in the formula are relative references, which means that these cells in the formula shift as the cell which is applying the conditional formatting also shifts.
In other words, cell A2 considers this as the formula:
=IF(LEN(D2)>0,IF(D2=0,TRUE,FALSE),IF(LEN(E2)>0,IF(E2=0,TRUE,FALSE),FALSE))
And cell B2 considers this as the formula:
=IF(LEN(E2)>0,IF(E2=0,TRUE,FALSE),IF(LEN(F2)>0,IF(F2=0,TRUE,FALSE),FALSE))
Notice how the formula had the cells shift over.
The problem occurs when it gets to cell C2, which considers the formula as this:
=IF(LEN(F2)>0,IF(F2=0,TRUE,FALSE),IF(LEN(G2)>0,IF(G2=0,TRUE,FALSE),FALSE))
Presumably neither F2 nor G2 contains the data you're looking for, which is why the conditional formatting rule is not applied.
To fix this, you can change the formula to an absolute reference so that it always refers to the D and E columns, like so:
=IF(LEN($D2)>0,IF($D2=0,TRUE,FALSE),IF(LEN($E2)>0,IF($E2=0,TRUE,FALSE),FALSE))
This way, all cells in the 2nd row will consider precisely the above formula when checking the formatting (i.e. the cells will not shift).
On a side note, parts of your formula are redundant.
= IF(<condition>,TRUE,FALSE)
is equivalent to just
= <condition>
And additionally, if a third argument in an IF statement is not specified, FALSE is the default.
That being said, this formula can be simplified to:
=IF(LEN($D2)>0,$D2=0,IF(LEN($E2)>0,$E2=0))
The user enters a date/time into cell B2. If this matches one of the values in column L I would like to format cell B2 as red, else format cell B2 as green.
Any idea how to do this?
Please format B2 green with standard fill, then apply the following Use a formula to determine which cells to format, Format values where this formula is true:
=match(B2,L:L,0)>0
with formatting (red) to suit and Applies to B2.
Assuming you are using Excel 2007 onwards:
Set cell shading for B2 = Green
Select Cell B2 and select the Conditional Formatting > New Rule menu item
Use a formula to determine which cells to format
In the formula bar, put in =ISNUMBER(MATCH(B2,$L$6:$L$100,0))
For format, change shading to Red
Obviously change the $L$6:$L$100 to suit you, but that should do it...
What about breaking this up into two steps.
Try putting a simple formula in Cell B1:
=ISNUMBER(MATCH(B2, L:L, 0))
This will return a TRUE if there's a match and a FALSE if there is not a match. Then make two conditional rules based on Cell B1.
I am trying to create a formula for Excel whereby a cell would change colour based on the text in the previous cell.
So for example if cell B2 contains the letter X and then B3 is Y, I would like B3 to turn green.
Equally, if B2 contains X and B3 contains W I would like B3 to turn red.
Any ideas much appreciated!
Select cell B3 and click the Conditional Formatting button in the ribbon and choose "New Rule".
Select "Use a formula to determine which cells to format"
Enter the formula: =IF(B2="X",IF(B3="Y", TRUE, FALSE),FALSE), and choose to fill green when this is true
Create another rule and enter the formula =IF(B2="X",IF(B3="W", TRUE, FALSE),FALSE) and choose to fill red when this is true.
More details - conditional formatting with a formula applies the format when the formula evaluates to TRUE. You can use a compound IF formula to return true or false based on the values of any cells.
Select ColumnB and as two CF formula rules apply:
Green: =AND(B1048576="X",B1="Y")
Red: =AND(B1048576="X",B1="W")
Use conditional formatting.
You can enter a condition using any cell you like and a format to apply if the formula is true.