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?
Related
In excel, I have the following:
I am trying to find the quickest and most user-friendly way to compare columns 2 and 1.
If a name in column 2 (in the format shown below) matches ANY of the cells in Column 1, the cell in Column 1 goes GREEN, indicating that user is PRESENT in Column 2.
I have played around with conditional formatting but would appreciate any direct and efficient solutions.
I was trying to adapt a version of this, but it failed to work:
=SUMPRODUCT(--(MID($A4&" "&$A4,FIND(",",$A4)+2,FIND(",",$A4&" "&$A4,FIND(",",$A4)+2)-FIND(",",$A4)-2)=$B$4:$B$33))
where the above formula was added on highlighting the first column and then ensuring the A4 referred to the first item in Column 1 and the B was the first and last item in column 2. As mentioned, this didn't work.
Update
Tried this as well but didn't work.
This answer written assuming column1 = column A, and column2 = column B
Apply a conditional format on column 1, set up with green background, with the formula =COUNTIF(B:B, A1)>0
Apply another conditional format on Column 1, set up with red background, formula =COUNTIF(B:B, A1)=0
Edit those formulas as necessary so that:
B:B is the address of column 2, the range you're looking in for each name
A1 is the address of the first (top-left) cell that the conditional format applies to.
You can select both columns and do Conditional Formatting, Highlight Cells, Duplicate Values. That would be the easiest way to compare. You can format the cells in the first list with red fill if you want them to be red and set the format for duplicate values with green fill. This will format it in the color scheme you showed. If the name is removed from the second column, the cell will go back to red.
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.
I have a 13x13 table of data on a worksheet that is comprised of links to another sheet.
For example the first row of 13 looks like:
=Sheet1!R7 =Sheet1!R20 =Sheet1!R21 =Sheet1!R22 =Sheet1!R23 =Sheet1!R24 =Sheet1!R25 =Sheet1!R26 =Sheet1!R27 =Sheet1!R28 =Sheet1!R29 =Sheet1!R30 =Sheet1!R31
I want to do conditional formatting over the entire table for when data from column R and column C of the same row are equal and >0.
For example;
When Sheet1!R7 is equal to Sheet1!C7 and >0, color the sheet 2 table (that has the link) red.
When Sheet1!R20 is equal to Sheet1!C20 and >0, color the sheet 2 table red and so on.
I would also like to repeat the process with a different colored fill if R == L and >0 but I can just use the same formula once I know how.
My attempt was =AND(Sheet1!R7=Sheet1!C7,Sheet1!C7>0).
This works for the single cell, but I'd like a way to do the whole table at once.
Any help is appreciated, thanks.
EDIT for clairty:
*I'm sure I'm not explaining it too well.
To put it simply, I have 2 columns of numbers, let's say A1:A169 and B1:B169.
I want to take the larger number from A and B for each row (A10 vs B10 etc, I used MAX function for this) and dump the output in column C.
I then aim to color code column C based on whether the number comes from column A or B. Red for A, yellow for B (no color for <0).
So far I have achieved all of this, I have the data sitting in a column color coded.
My problem comes in that I want to have the 169 numbers in column C in a more readable format, I.E. in a 13x13 grid table. I don't know how to do this and keep the color coding!*
I suppose I can offer you some possible solution.
Lets say you have sheet1 and sheet2. In sheet2, you have links to
sheet1 as you mentioned. And my understanding is that you want to color
the sheet2 (the entire table?) as red if a certain condition is met.
This is how it might be done.
In sheet 2, create a formula for a cell which reflects your condition. Lets say that is =IF(Sheet1!A1="foo", 1, 0). You can add your AND conditions in that if statement. So that cell will contain 1 if the condition is met and 0 if not met.
Select the range of cells in sheet2. Click conditional formatting. Select "use a formula to determine which cells to format". Enter the condition for the calculated value in sheet2. For example, in sheet2, my cell G1 is the result of the formula =IF(Sheet1!A1="foo", 1, 0). So if the value of G1 is 1 then I want to color the range Red.
So in essense, we are using a formula to calculate the value of a cell and using that value
as a condition to format a range of cells in Sheet2.
Hope this helps.
Hopefully this will stop the chain.
See the linked questions if you want more background, but I need to conditional format multiple rows (2,000+) from the FIRST (leftmost) non-blank cell + the next 11 columns after it. Not sure if it's needed for the conditional format formula, but I am able to get the start cell for each row, can kind of get the end cell (see below).
Cell address of the first populated cell in the row (*the data starts on row 2, the values begin in column C and end in column P):
{=(ADDRESS(2,COLUMN(INDEX(C2:P2,MATCH(1,IF(C2:P2<>0,IF(C2:P2<>"",1)),0)))))}
^ this gets me an absoluted text-version of the leftmost populated cell in each row. I have all these addresses in a helper column. I am then able to get the desired stopping-point for the format (12th cell to the right of the cell returned from above formula), but I have to manually enter the cell address derived from above formula:
=ADDRESS(2,COLUMN(OFFSET(N2,0,11,1,1)))
I can't nest the start cell formula inside this second formula or it breaks.
THANK YOU!
Desired result (ignore the different colors, they can be the same):
I added a helper column C that finds the first non blank in the row (my data went from column D to column AZ)
=MATCH(TRUE,INDEX((D2:AZ2<>0),0),0)
My conditional format rule applied to D2 to AZ4 was to highlight when the following was true:
==AND(COLUMN(D2)<($C2+11+COLUMN($D2)),COLUMN(D2)>=$C2+COLUMN($C2))
You can modify this to put the helper column where you wish, and to use named ranges.
(Had to add condition to not start coloring before the first instance!)
Trying to create a Gantt chart look in Excel. I have two columns, A and B (A = start date, B = End Date).
Across the top of the page (Row 2) I have a column with a date for every date of the project (custom formatted with "d" for readability, with the name of the month in Row 1.)
I'm now trying to apply conditional formatting rules to turn the cell in the column a specific colour (say, green) if:
the value in A[this row] is greater-than-or-equal-to [this column]2.
and
the value in B[this row] less-than-or-equal-to [this column]2.
I've dug through a few answers recommending ADDRESS() and INDIRECT(), but I'm stumped on getting this to work. Any thoughts?
You can use AND to combine the conditions. I'm assuming the 'Gantt chart' starts as from column C and the active row is 2 here.
Select C2 and the rest of the row (to 31, 30 or 28/29 depending on the number of days in the month).
Pull up conditional formatting with formula and put:
=AND(C2>=$A2,C2<=$B2)
Pick the format fill green and that should do it
In conditional formatting if you use the first cell of your selection in the formula it automatically turns that into a relative formula.
For example if you use the formula: =A1>5 and select cells A1:B5 it will check each cell to see if its >5 not just cell A1 (so it automatically increments the row and the column for you). Usually this is preferred over using indirect but sometimes indirect is necessary.
So using indirect you can utilize the row() and column() functions. So in your example:
the value in A[this row] is greater-than-or-equal-to [this column]2.
and
the value in B[this row] less-than-or-equal-to [this column]2.
Would look like:
=AND(INDIRECT("A"&ROW()) >= INDIRECT(CHAR(COLUMN()+64)&"2"), INDIRECT("B"&ROW()) <= INDIRECT(CHAR(COLUMN()+64)&"2"))
Hopefully that helps
It works for me without ADDRESS or INDIRECT. This is the formula inside the conditional formatting. If I have to guess what's going on, it's most likely that you are not placing the proper anchors ($).
=AND(C$2>=$A3,C$2<=$B3)