Multi-function conditional formatting cell range - excel

I want to give a quick indication using coloured cells of the time likely to be taken to complete a task. So for example:
if cell B2 = 1 then fill cell range G2:H2 with light red
if cell B2 = 2 then fill cell range G2:J2 with light red
if cell B2 = 3 then fill cell range G2:L2 with light red
How might I achieve this?

Select G2:H2 and use a CF formula rule of:
=$B$2=1
Select G2:J2 and use a CF formula rule of:
=$B$2=2
Select G2:L2 and use a CF formula rule of:
=$B$2=3
each with the formatting of your choice.

If you want a dynamic formula and only one format setting you can select all the cells you want to format, then make a new conditional formatting rule using the formula:
=$B$2*2+COLUMN($G:$G)-COLUMN()>0
Which will affect 2 additional cells each time you increment $B$2.
I used your examples of $B$2 and starting with $G:$G but you can change those if needed.
If you need multiple format settings this won't work.

Related

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:

Excel - Conditional Formatting: If the cell above is different, change fill color

So the problem I have is trying to change the fill color using conditional formatting in excel. This is basically what I want to do:
First I have a column, something like this:
1
1
1
2
2
3
4
4
4
Now I want to use conditional formatting to check if cell A2=A1, if it is to have fill color #1, and so on. Once it gets to cell A4 and it checks that A4=A3, if it does not match I want it to switch the fill to fill color #2, and it continues to check. Basically every time the cell does not match the value of the cell above, to switch to a different fill color.
I tried using the OFFSET function to check if that value was the same as the cell above, that worked but once I added the function to conditional formatting it went all funky and did not change colors.
Using your sample data, say you put them into cell A1 to A9, highlight cell A2:A9 only, and set up the conditional formatting as shown below.
For duplicated value you will use =A2=A1
For different value you will use =A2<>A1
select a cell outside of your table (let's say it's Z1) and fill it with the value: AB
cell B1 value: A
in all cells from B2 downwards: =IF(A2=A1,B1,SUBSTITUTE($Z$1,B1,""))
it means that if A2<>A1, B2="B"; if A3=A2, B3=B2="B"
fill all cells on column A with the color you want for "cluster" B: let's say it's blue
add "$B1="A" in conditional formatting, filling = red

Need formula for a range of cells - to highlight cells based on the presence of a value in another range of cells

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!

Conditional Formatting for Blank Cell Does not Give Expected Result

I am trying to format a cell, the goal is to have a Green Fill if the adjacent cell (on left) is blank and Red Fill if not blank. Below is the Code applied to Column D
="ISBlank(($C$2)"
and a snapshot below target cell
I am not getting the Desired result, the cells in column D remain white (excel default format of cells)
Please see the Data I am using below
I don't think you need the $ before the 2 in =ISBLANK($C$2) otherwisethe conditional formatting will only refer to C2. I think you'll want:
=ISBLANK($C2)
Also if the contents in column C is ="" , ISBLANK will return FALSE, assuming you don't want that behavior, you could try:
=LEN($C2)>0
Which checks how long the text is in C2.
Example:
Occasionally I've also had trouble getting is blank() to work properly. What I would try is:
$d$2 = ""
1] Do way with the double inverted commas
2] The Applies to range must be more than a single cell if you want the CF to apply across a range of more than one cell
3] You don't need two rules
Select ColumnD and 'standard' fill red. (Remove fill from D1 if preferred). Select ColumnD (this sets the Applies to range) and HOME > Styles - Conditional Formatting, New Rule..., Use a formula to determine which cells to format and Format values where this formula is true::
=ISBLANK(C1)
Format..., select green Fill, OK, OK.
You do not need to lock the column reference because you are only applying the CF to a single column. You must not lock the row reference if to apply to multiple rows on a row by row basis.
With the above if a cell is red and has an apparently empty cell on its left then that cell is not actually empty.

Conditionally format one cell based on values in a column

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.

Resources