My question is, how to set the row value dynamically in a conditional formatting formula, i.e.
=D$1=0
where the 1 has to be replaced dynamically with a value hold in a specific cell (first column = $A and related row = 8)
Example: Assume a number of employees with a distinct ID, a range of cells to be conditionally formatted according to true or false entries in another range associated to the employees IDs. The column part of the reference in the written formula is fix (the column to be formatted). The row value is fix too. The employees name depends on the ID and inserted by VLOOKUP. Each field in the to be formatted range is representing a task to do. When I now have to assign a task to a different employee I can simple change the ID in front of the name and via VLOOKUP a new employees name will appear. Unfortunately the conditional formatting has to be customized in addition because the row number is not dynamic. 5 Employees means I have 5 conditional formatting formulas.
What I want is: Only one conditional formula
D8 has to be yellow when D1 is '0' (ID is 1 = Alex). I now change A8 to ID 5 = Mark. D8 has to change to white because D5 is '1' The ID has to be the row part of the formula.
The column part is fix 'D' but the row part has to be the number of the ID dynamically.
Sample excel screenshot:
How to solve this problem? Hope the question is not only confusing and maybe helps to build more flexible excel sheets.
You could try using an INDEX formula for this purpose:
=INDEX($D$1:$H$5,MATCH($A8,$C$1:$C$5,0),COLUMN()-3)=0
I think I solved the problem, never found it without the index hint from maxhob17.
=INDEX(D$1:D$5;$A8)=0 as the formatting formula placed in cell D8
That means search matrix D1 to D5 in row given through ID in A8
=$D$8:$H$12 that formula will be applied to that area
The rest is done by excel itself. Be aware of relative and absolute cell
references
Related
Need Help on Named Ranges in Formulas:
I have a second workbook ('TEST.xlsx') as the destination, referencing worksheet-scoped named ranges (in 12 columns X 75 rows) in the source workbook ('FLOW.xlsx'). I want to create a formula that will match a look-up value (a date entered into cell C3 in TEST that will return the matching named range IF there are 2 or more blank cells in that matched named range/column and the remaining named ranges/columns in that set of 12 columns with 2+ blank cells. The 12 separate columns in the source workbook ('FLOW') are named by month, year and location (ex., "jan_2019_class.1","feb_2019_class.1", etc.), the worksheet columns being C, H, M, R, W, AB, AG, AL, AQ, AV, BA, and BF. The rows are 80-155. I've only been able to make a simple working COUNTBLANK formula in my TEST workbook, ex.:
=COUNTBLANK('[FLOW.xlsx]Class_1-Chart'!jan_2019_class.1)
But NOT for successive columns (with different named ranges and the columns are non-sequential); and I can't figure out the functioning formula to combine with this to get the count AND data returned by criteria as described above. Please, no VBA/macros.
Thank you in advance for the help!
'TEST.xlsx' Screen Shot-RVSD
FLOW.xlsx- sample screenshot
There are many approaches but I personally prefer the use of helper rows/columns/cells and named ranges.
In my demonstration I used two class attendant schedule in two different year from January to June as shown below (they are sitting in Column C to M in my example):
As shown above, I have added two helper rows on top of each schedule. The first helper row is used to find out if there is 2 or more vacancies in each month, if so returns TRUE. I have given the name check.2019.class.1 and check.2021.class.5 for each of them.
The second helper row is simply showing the range name of each month such as jan_2019_class.1, feb_2019_class.2 etc. I have given the name NameRng.2019.class.1 and NameRng.2021.class.5 for each of them.
On the TEST sheet I have the following set up:
where the look up value in cell C3 is actually returned by a formula so it can be "dynamically" changed by the user. Please note in the following formula I used a name ClassNo which is essentially the value from cell B3.
=B2&"_"&B1&"_class."&ClassNo
I have also named cell C3 as Start_MthYrClass which will be used in my following formula.
The formula for looking up the first available month in 2019 if the start month is jan_2019_class.1 is:
=INDEX(NameRng.2019.class.1,MATCH(1,(TRANSPOSE(ROW($1:$11))>=MATCH(Start_MthYrClass,NameRng.2019.class.1,0))*Check.2019.class.1,0))
Please note it is an array formula so you MUST press Ctrl+Shift+Enter upon finishing the formula in the formula bar otherwise they will not function correctly.
The logic is to first "filter" the range NameRng.2019.class.1 using this formula =TRANSPOSE(ROW($1:$11))>=MATCH(Start_MthYrClass,NameRng.2019.class.1,0), in which ROW($1:$11) represents {1;2;3;4;5;6;7;8;9;10;11} and TRANSPOSE will turn it into {1,2,3,4,5,6,7,8,9,10,11}. This range of numbers represents the column index in that specific range which is Column C to M (in your case it would be ROW($1:$56) as your data is in Column C to BF). Then I use MATCH to return the start column index of the look up month jan_2019_class.1, and it should return 1 as this month starts in the 1st place/column in the range NameRng.2019.class.1. So this is what I am actually comparing: {1,2,3,4,5,6,7,8,9,10,11}>=1, and it will return {TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE}.
Then I multiply the above result with range Check.2019.class.1 which is essentially {FALSE,0,FALSE,0,TRUE,0,FALSE,0,TRUE,0,TRUE}. Then I will get {0,0,0,0,1,0,0,0,1,0,1}. FYI in Excel TRUE=1 and FALSE=0, so TRUE x FALSE = 0 while TRUE x TRUE = 1.
Lastly, I use MATCH to find out the position of the first 1 in the above result which is the 5th place/column, and then use INDEX to return the corresponding value from range NameRng.2019.class.1 which is mar_2019_class.1.
Here is a more universal formula which allows you enter it in the first cell C6 and drag it down to apply across board, if you have given names to the relevant cells and ranges in the same way as what I have demonstrated.
=IFERROR(INDEX(INDIRECT("NameRng."&B6&".class."&ClassNo),MATCH(1,(TRANSPOSE(ROW($1:$11))>=MATCH(Start_MthYrClass,INDIRECT("NameRng."&B6&".class."&ClassNo),0))*INDIRECT("Check."&B6&".class."&ClassNo),0)),"")
It is also an array formula so you MUST press Ctrl+Shift+Enter upon finishing the formula in the formula bar.
It is essentially the same formula as the first one but I have added IFERROR to return a blank cell if there is no match, and I used INDIRECT to refer to the named ranges dynamically based on the year and class number chosen.
Now, if I change the look up criteria to mar_2021_class.5, here is an updated result:
Let me know if you have any questions. Cheers :)
A list of names (Sheet "Name") which need to put on the following sheet in 5 (preferably variable number) row gaps.
A3 = Name!A1
A9 = Name!A2
A15 = Name!A3
A21 = Name!A4
I've tried using the ROW() in conjunction with IF/THEN/ELSE condition loop,checking for blank row, which fell short. More googling has lead me to the the offset() operand but that's accessing cells rather than writing in them.
I'm quite happy to use VBA active cell but the VB editor doesn't work properly on this machine so for the time being i'm trying to solve this task using EXCEL.
Ooption A:
Put this formula into A3,
=INDEX(Name!A:A, INT(ROW()/6)+1)
Copy to A9, A15 and A21.
Option B:
Put this formula into A3,
=IF(NOT(MOD(ROW()-3, 6)), INDEX(Name!A:A, INT(ROW()/6)+1), "")
Fill down to A21.
Alternatively, you can offset based on the number of rows you've already filled.
=OFFSET(Name!$A$1,counta(A$1:A2),0)
This will work as long as there is no content within other rows between A3,A9,A15,A21.
A little more dynamic would be to add a reference row in the Name tab that would allow you to do a VLOOKUP/MATCH/etc within the new tab. That is very handy when you want to make a variable number of rows in the new tab for each row in the other tab (for example, table 1 lists a quantity and you need a row for each quantity in the next tab--the lookup reference would be a cumulative sum of all of the quantities and you could lookup to that reference).
I’m wondering if someone can assist with a conditional formatting issue i just can't wrap my head around
We currently have a table with names in and next to the name a number
Bob 5
Michael 6
Now if i type bob in cell A1 i would like it to highlight that row and the four below it.
another example would be if i type Michael in cell A1 it would highlight that row and 5 below that
any help is appreciated
I couldn't write a simpler formula, but that one worked with the data I tested.
A1 will be where names will be inserted.
The table will range from C1 to D7 (assuming there are no column labels).
Select the table C1 to D7 and insert conditional formatting with formula and use the formula:
=AND(COUNTIF(OFFSET(C1,IF(ROW()-VLOOKUP($A$1,$C$1:$D$7,2,0)<=0,1-ROW(),1-VLOOKUP($A$1,$C$1:$D$7,2,0)),0,VLOOKUP($A$1,$C$1:$D$7,2,0)),$A$1)>0,ROW()>=MATCH($A$1,C:C,0))
And pick the formatting your want.
The formula checks two conditions:
COUNTIF(OFFSET(C1,IF(ROW()-VLOOKUP($A$1,$C$1:$D$7,2,0)<=0,1-ROW(),1-VLOOKUP($A$1,$C$1:$D$7,2,0)),0,VLOOKUP($A$1,$C$1:$D$7,2,0)),$A$1)>0
This checks if there is at least 1 match within a designated range depending of the value in D. It will check if there is a match x rows above the current row where x is the value. If there is, the we get the first boolean value (true or false).
The second ROW()>=MATCH($A$1,C:C,0) ensures that the match is above or on the current row.
Google Spreadsheet Demo
I'm trying to re-do a spreadsheet.. Without having to put an =if into every cell where the data would be variable depending on the selection of a drop down (Which is how it is set currently :( )
On the main sheet.. Cell J1 i have a dropdown selection.. And im looking for the cells in
A1-F1 to be populated with the information on the data sheet.. Based on the selection either 1 or 2 in this example but i cant figure out how to do this
Any help would be appreciated
This is what VLOOKUP functions are for. VLOOKUP functions search for a key in the first column of a range, and matches the selected row on it.
You can just put =J1 into your A1 cell, and on your B1 cell you can search for A1 as =VLOOKUP($A1,Data!$A$1:$F$2,2,FALSE). This formula can be read like this:
"Please, search for the value that it's in $A1 in table Data!$A$1:$F$2.When you got it, get me the column 2. Ah, by the way, if you asked me if the key column is made of sorted numbers, so if you can't find it, you can extrapolate linearly, I'd answer FALSE, got it? Thanks a bunch!"
So, in your C1 cell you'd ask for the column 3, and so on. Of course, if you'd like to just create a single formula, you can insert a row over your row 1, and put the column references over the cells, as this:
In this case, my formula on B1 is =VLOOKUP($A2,Data!$A$1:$F$2,B1,FALSE) - which can be dragged to C1:F1. Of course you can later hide the row 1 from your user.
Hope that helps.
I have a sheet in Excel where the columns contain different names of people that are in different teams in my department (i.e. Names in Column 1 are in Team 1).
For another sheet, I need to have a formula that achieves the following:If I write a name in Cell B2 that can be found in the first column of that other sheet (Team 1), Excel should populate cell B6 with "Team 1".
If instead, the name I wrote is found in the second column, then the text should read "Team 2".
I've tried a couple of different formulas w/o success, and stringing a lot of IF and OR functions together is way too cumbersome. Anybody has a better solution?
If you need this formula for more then only two column then id use the formula
=INDEX(Sheet1!C1:G1,SUMPRODUCT((Sheet1!C2:G6=B1)*COLUMN(Sheet1!C2:G6)))
Say you have a set-up like:
And in B1 of Sheet2 you enter Name3, you want it to return TEAM1 as shown below:
The only catch to this formula is that you will need to tell it how many columns are before your data so if you have a table more like:
Then you need to tell the formula that there are 2 rows before your data starts, your new formula will be
=INDEX(Sheet1!C1:G1,SUMPRODUCT((Sheet1!C2:G6=B1)*COLUMN(Sheet1!C2:G6))-2)
Notice the -2 before the last parenthesis this is to indicate that there are 2 columns BEFORE you data.
and the new result for looking up say NAME20 would become as follows:
*EXPLANATION: *
The formula works as follows , I will do it all on one page for easier viewing and instead of Sheet2!B2 and B6 I will use G2, and G6 on the same sheet as the data.
First we look at all values in the Range A1:E6 and find the one with the matching name so we use
=A1:E6=G2
Now when you enter this into the cell you will recieve a #VALUE,but if you goto the Formula Bar and press F9 it will shwo you the full value of the formula
{FALSE,FALSE,FALSE,FALSE,FALSE;FALSE,FALSE,FALSE,FALSE,FALSE;FALSE,FALSE,FALSE,FALSE,FALSE;FALSE,FALSE,TRUE,FALSE,FALSE;FALSE,FALSE,FALSE,FALSE,FALSE;FALSE,FALSE,FALSE,FALSE,FALSE}
In this we know that one cell contains the Name we searched for, this is represented by the TRUE
Now when using a formula like SUMPRODUCT, FALSE = 0 and TRUE = 1
So to get the column we mutiply every result by the column they are in.
=SUMPRODUCT((A1:E6=G2)*COLUMN(A1:E6))
So any cells that don't =G2 are FAlSE or 0, and when you multiply the column of that cell by 0 (because false = 0) it will simply result in 0. But for the one cell that IS TRUE or 1 When you multiply the column of that cell by 1 (because TRUE = 1) The product will be the cells column number
So as shown in the picture when looking for NAME13 the result of the sumproduct is 3 (its column)
Then to return the TEAM for that name, we use the INDEX function will return the value in a cell at the given cordinates.
In this case we want the value from A1:E1 that is in the same column as the Name we matched. When looked at as an Array A1:E1 looks like
{"TEAM1","TEAM2","TEAM3","TEAM4","TEAM5"}
And we want to return the value in that array at the same position as the column number of our cell, Minus any nonincluded column before the data, thus the reason for the -2 in the secon example I gave you.
So:
=INDEX(A1:E1,SUMPRODUCT((A1:E6=G2)*COLUMN(A1:E6)))
In this example excel interprets this formula as
Return the 3rd value (the 3 comes from the sumproduct as explained earlier) in the list of value from A1:E1. And that value would be TEAM3.
use a MATCH() or VLOOKUP() function inside an IF(). SOmthing like:
IF(NOT(ISERROR(MATCH(...)));"Team1";"")
Did you know you can browse functions by catergoty (such as Search), just clikc the fx left of your formula bar and use the drop down box. Each formula comes with a description with usually rather clear information...