I'm trying to use conditional formatting to highlight the lowest value in each row green as long as the unmerged cell above it does not read "N" (as I want that to disqualify the value in that case.) If the lowest value has the "N" (for No) above, I need to have the next lowest value highlighted green that doesn't have "N" listed. I have conditional formatting to highlight a value red if "N" is selected/entered. In my screenshot, the value in cell F11 is the lowest, but because it has an "N" above, the value in cell D11 should highlight green (with F11 staying red- If I change that N to Y, the cell turns green.)
Each item's "row" is made of two rows. On the upper row, the cells are unmerged. On the lower row, both cells are merged. The range of columns that I want to evaluate is D:CY (with CX being the last for the lower row since it has merged cells.)
Here is where I'm at with the custom formula:
=D11=IF(E10="N",SMALL($D11:$CX11,2),MIN($D11:$CX11))
I will be using this on versions as old as Excel 2013, in case that affects code support. I want to apply this to a range or rows below so I'm not sure if I've got my absolute $ addressing correct. The columns won't change except that E10 since I'd then want it to move down the row...
Perhaps a formula like this for your conditional formatting, based on COUNTIFS with staggered ranges to identify the lowest cell with a Y one row above and one column to the right:
=AND(D11<>"",E10<>"N",COUNTIFS($D11:$H11,"<"&D11,$E10:$I10,"Y")=0)
Change the H to CX and the I to CY to apply to your range.
Related
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:
Sheet1
[
Sheet2
[
On Sheet 1 I have four columns Col A= 1st adjustment, Col B= 1st Check, Col C= 2nd Adjustment, Col D= 2nd Check.
The values in these columns are either 0 or non 0. Always a number. For the two adjustment columns I format them to be Red (if they are non-zero) and for the two check columns I format them to be Yellow (if they are non-zero).
On sheet 2 there is a column that pulls and combines the the sets of adjustments and checks and assigns them to the correct employee ID #.
Somehow I need the formatting on the column in sheet 2 to be red if the number came from an adjustment column on the other page and yellow if the number came from a check column on the other page. And no color if it is equal to 0.
What is the best way to do this? I have not been able to find a solution.
The conditional formatting rules I have are all applied to column C Sheet 2. They are:
#1- Cell value equal to = 0 (no fill)
#2 Cell value equal to =Sheet1!$E1 (yellow fill)
#3 Cell value equal to =Sheet1!$C1 (yellow fill)
#4 Cell value equal to =Sheet1!$D1 (red fill)
#5 Cell value equal to =Sheet1!$B1 (red fill)
Assuming that both lists start in A1, put this formula in cell D2 of Sheet2:
=IF(C2=0,0,IF(C2=INDEX(Sheet1!$B$2:$E$7,B2,(A2-1)*2+1),1,2))
Then select the range C2:C13 and open the conditional formatting menu. Add 3 new rules based on formula. The first formula is:
=D2=1
and set the format as filled in red. The second formula is:
=D2=2
and set the format as filled in yellow. The third formula is:
=D2=0
and set the format as unfilled (which is not the same as no format selected). This last rule is not strictly necessary if none is going to change the format of your range manually. Still...
Note that each formula for the conditional formatting is written without any $ that would lock the reference. Therefore each cell in the range $C$2:$C$13 will translate that formula relatively to its own position. Cell C2 will "look into" cell D2, cell C3 will look into cell D3, C4 into D4 and so on. You can of course hide column D and the conditional formatting will still work.
You could also make it without using an extra column. Just edit the formula meant for cell D2 accordingly and use it in your rules. Something like this should work:
=IF(C2=0,0,IF(C2=INDEX(Sheet1!$B$2:$E$7,B2,(A2-1)*2+1),1,2))=1
=IF(C2=0,0,IF(C2=INDEX(Sheet1!$B$2:$E$7,B2,(A2-1)*2+1),1,2))=2
=IF(C2=0,0,IF(C2=INDEX(Sheet1!$B$2:$E$7,B2,(A2-1)*2+1),1,2))=0
Formula details (as asked in comments)
B2 is for the row. In the context of the INDEX function it says at what row of the range ($B$2:$E$7 in the formula we see here) the INDEX function has to "look". If B2 is 1, it will consider the first row of the range (in our case row 2). If it's 2, it will consider the second row (in our case row 3).
(A2-1)*2+1 stands for the column. In the context of the INDEX function it says at what column of the range ($B$2:$E$7 in the formula we see here) the INDEX function has to "look". If the result is 1, it will consider the first column of the range (in our case the B column). If it's 2, it will consider the second column (in our case the C column).
About (A2-1)*2+1: let's change it a bit so it will be easier to visualize while i explain it:
1+(A2-1)*2
We can divide the formula in 2 parts: the 1 which stand as our starting point (the first column) and the (A2-1)*2+1 which deal with the shift in columns according to the shift in weeks. In cell A2 we find the number of the week. In the first sheet we have 2 columns for each weeks. Therefore when the week shifts by 1, our target column will have to shift by 2. We can't just multiply by 2 the week sheet because it's the shift from the first week that counts for 2, not the actual value. At the first week we will have no shift. Therefore our shift will have to be 0; but we can't just use a 0 because there is no "zero column" in a range. Therefore we need to have our starting value of 1 that is summed to the shift. This way for the first week we will have:
1+(1-1)*2
1+(0)*2
1+0
1
First column of the range $B$2:$E$7 (which is column B). For the second week we will have:
1+(2-1)*2
1+(1)*2
1+2
3
Third column of the range $B$2:$E$7 (which is column D).
Over all the formula IF(C2=INDEX(Sheet1!$B$2:$E$7,B2,(A2-1)*2+1),1,2) basically checks if the value in C2 is the same as the first column of the given week. If it's the same value it returns 1, otherwise it returns 2 (basically assuming that the value will be equal to the one in second colum of the given week).
Report any question you have or bug you have encountered. If, according to your judgment, this answer (or any other) is the best solution to your problem you have the privilege to accept it (link).
Let me give you a general approach for conditional formatting, based on a formula:
First you try to set up your formula, which you enter in some cell. The result of the formula should be TRUE in case you want the formatting to be applied, and FALSE in all other cases.
Please edit your question again, showing the formula you have tried for configuring this.
Oh, you just want to copy the formatting of that first sheet. But tell me, how is the formatting of that first sheet determined? Is it also the result of a conditional formatting? And about the numbers of the ADJ/Check column, is that just the sum of the values in the first sheet?
I have a spreadsheet that has a 7000 rows. My sheet does have a header row. Column G is not supposed to have any cell with a value greater then 1000. I want to highlight red the cells with these "bad values". This I accomplished with the conditional formatting cell value greater then 1000 and applied it to G2:G10000. even though I would love to apply this G:G, so that I don't limit this to just 10,000 rows (there may be rows ith future then the current 7,000).
My bigger issue is that to highlight that column G has a "bad" cell(s) I would lime to highlight all of column G.
I tried using a conditional formatting formula = $G2>1000 and applied it to G:G it only highlighted the cell. I tried = $A2>1000 and applied it to G:G, It highlighted the entire column always even when the condition wasn't met.
What do I do?
You can accomplish this with a COUNTIF formula. I mis-read and did this for a value greater than or equal 10,000. Take out one of my ZEROs in the equation!
As the solution stands, if any cell in column G exceeds (or equals) 10,000, the entire column will highlight.
I want to change color of the gray line in below chart (format - red to decrease and green to increase) every month. How can I do that?
I used the following table in this workaround (starting from A1), filled B2:C10 with zeroes and created a line chart with values from cell range B2:C10:
Please note that I used the following formula for "Up" column and "Down" column, respectively:
=IF(COUNT($A1)>0, IF(OR($A2<$A3, $A2>$A1), $A2, "delete"), IF($A2<$A3, $A2, "delete"))
=IF(COUNT($A1)>0, IF(OR($A2>$A3, $A2<$A1), $A2, "delete"), IF($A2>$A3, $A2, "delete"))
What the formula does is check first if the value above the current checked cell is a number. If it is a number, for "Up" column formula, it checks the current checked cell's value if it is greater than the value above it or less than the value below and display that value if true or delete if not. For "Down" column, it's just the opposite value checking. Just tweak the formula to adapt if there's no change in the value.
Steps
Replace the values in B2 and C2 by pasting the formula above in their respective columns.
Select cells B2 and C2 and paste them to the rest of the rows (B3:C10). Select cell range B2:C10, copy and paste as value. There should be no formula left in cell range B2:10.
Using cell range B2:C10, find and replace delete with blanks.
So it becomes like this:
Replace the line colors with the ones you want to use.
In Excel 2007, I've conditional formatting for column Q:
values > -5 = green
values between -5 and -25 are yellow and
values less than -25 are red.
I want cell P5 to have the same color as Q5, Cell P6 to have the same color as Q6 and so forth.
The value in cell P5 is dependent on a formula (K5-C5),
the value in cell P6 is dependent on a formula (K6-C6) and so forth.
How can I change the color of the cells in column P so they are equal to their "matching" cells in column Q, without ruining the formulas created in column P?
If I have understood you correctly, then you don't need VBA for this. Simply highlight the relevant range and not just column Q while conditional formatting. See this example
I have not bothered with cutoffs since for example you have not specified the formatting you required for a cell in ColumnQ with value -5.
For consistency with the details in your link, I have assumed that the likes of values >-5 refer to -5% rather than -5.
To change the color of the cells in column P so they are equal to their "matching" cells in column Q, without ruining the formulas created in column P apply Conditional Formatting (which does not alter the actual cell content, only its appearance).
To format ColumnP cells according to rules determined by ColumnQ cells adjust the range to which the formatting is applied. Roughly, determine the format for Q and apply that to P:Q.
Since three colours are involved CF will require at least two rules where determined by formulae (a third colour could be applied by 'standard' fill, which CF rules override).
Formula rules as below appear to meet my limited understanding of your requirements:
Green: =$Q4>-0.05
Yellow: =AND($Q4>-0.25,$Q4<0.05)
Red: =$Q4<0.25
For the example I chose the applicable range for each as:
=$P$4:$Q$12
Note:
These do not directly address transition values such as -5%
Empty cells will also be formatted
The order of the rules makes a difference