excel indirect cell reference and index rows - excel

I want to reference the worksheet name and then transpose the totals in row 1 to a column in my summary worksheet.
I have found the following formula, which looks up a worksheet and takes the total, then I can paste this down to look up the row, essentially transposing row H1 to AG1 to column B on my summary worksheet.
=INDEX('201510'!$H$1:$AG$1,ROWS(B$1:B1))
Now I want to replace the direct ref to the worksheet tab to a lookup. So when I type the worksheet name in say row 2, it will give me the monthly totals.
This formula looks up the tab reference in B2 and displays the contents of H1. Where B2 has the worksheet name.
=INDIRECT("'"&$B$2&"'!$H1")
However when I copy this formula down the column, H1 does not change to H2. Furthermore, I need it to transpose vertically to I1.
How can I combine the two formulae?
Thanks,
Andy

You will need to combine the logic of an INDIRECT function with regular Excel referencing. Note that in your final formula, the "'!$H1" is text, meaning Excel doesn't try to compute it until it calculates the value of the cell. ie: it does not compute that what you are typing is a reference, just text.
So, assuming you continue to use the INDIRECT function, you will need to create the address of the final portion dynamically. There are many ways to do this. For example:
=INDIRECT("'"&$B$2&"'!H"&ROW()-1)
This version takes the string of the sheet name from B2, and then adds on the "'!H" as an additional string, and then takes the row as the current row number of the cell above the cell the formula is in. ie: if this formula is in D2, it will look up H1 on the other sheet. This method relies on your formula being in a consistent position within your sheet - if you insert a row above this one, it will change what ROW() calculates as, thus changing the formula.
Another method would be to reference H1 in a way that consistently points there, and also iterates into higher numbers as you drag down the formula. This method may be more useful for your purposes, as it also teaches another function:
=INDIRECT(ADDRESS(ROW(H1),COLUMN(H1),,1,$B$2))
Note that the ADDRESS function creates a string which shows the way a direct reference to a specific cell would. with the arguments I have above, it picks up the row number of H1 [iterating down, as there are no $ in front of the 1], the column number of H1 [iterating to the right, as there is no $ in front of the H], and the sheet name from $B$2.

Related

Reference named ranges in external workbook with formula criteria

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 :)

Every n rows down select the next row from another sheet

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).

Excel string to criteria

I have an Excel formula like this:
=SUM(SUMIF(A2:A11;{"1010";"1020"};B2:B11))
Now I need to make the formula more dynamic. Instead of changing the formula itself, I should be able to change some cell (linked in the formula). This change will be reflected in the formula.
Ex:
=SUM(SUMIF(A2:A11;D2;B2:B11))
Cell D2 should return something similar to {"1010";"1020"} in the first formula.
I tried this and it works only if in the column D I have one value (ex: 1020), but if there are two values (ex: 1010;1020) it returns 0.
This is how my table looks like:
As you can see, it shows 0 for the cell where D2 has two values; but it works when there is only one value. All the rows in column D will be like cell D2, with 2 or more values, this is why it has to be dynamic using a list in the formula.
How can this be achieved in Excel? How can I make a list from the cell?
Using multiple cells would be easier! If the formula cell is one to the right of the criteria cell, you can define a named formula (Using Name Manager) called, say, GetList, which refers to this formula:
=EVALUATE("{"&INDIRECT("RC[-1]";0)&"}")
Then your formula becomes:
=SUMPRODUCT(SUMIF(A2:A11;GetList;B2:B11))

populate Excel Formulas in the an entire column after changing some of the formula values

I have two excel sheets. The one that contains the data "gdsc_en_input_w2" and the other one will contain a selective number of cells from "gdsc_en_input_w2".
I am using the current formula:
=INDEX(gdsc_en_input_w2!$A$1:$YE$13848,MATCH("AKT2",gdsc_en_input_w2!$A$1:$A$13848,0),MATCH($A$3,gdsc_en_input_w2!$A$1:$YE$1,0))
I want to fill an entire column in the second sheet by referencing columns in the "gdsc_en_input_w2" sheet but based on the values stored in the column $A$1:$A$13848. As you can see the second match() matches only $A$3 ...is there a way to fill the required column with the formula with incremental column reference in the second match() function in the formula above. in other words I want to fill in the second cell of the target column the following formula :
=INDEX(gdsc_en_input_w2!$A$1:$YE$13848,MATCH("AKT2",gdsc_en_input_w2!$A$1:$A$13848,0),MATCH($A$4,gdsc_en_input_w2!$A$1:$YE$1,0))
note that the match now has $A$4 instead of $A$3.
Assuming that I am understanding what you are wanting, this formula is going to be in one column where each subsequent row will have a higher number (3,4,5,...) If that is the case, unlock your formula to read:
=INDEX(gdsc_en_input_w2!$A$1:$YE$13848,MATCH("AKT2",gdsc_en_input_w2!$A$1:$A$13848,0),MATCH($A3,gdsc_en_input_w2!$A$1:$YE$1,0)) (I removed the $ in-front of the 3)
Paste that into the whatever your starting cell is, then auto-fill

EXCEL: Need to find a value in a range of cells from another worksheet and return value from adjacent cell

I am trying to find the formula that will search in column A (of worksheet "ABC") to find a value matching G4 in worksheet "XYZ" Once that value is found, return the value of the cell adjacent (column B of "ABC") to the cell in which this formula exists in worksheet "XYZ". All sheets are in the same workbook.
Thank you so much!
here's an example of what you're describing:
In spreadsheet ABC, you have a reference value in column A and data in column B
In spreadsheet XYZ, you have a matching number in column A. You'd like to pair the data from spreadsheet ABC to the value in XYZ:
If you notice the formula in the formula bar on the second picture, you'll see the vlookup formula to pull the data for this example. I also added an apostrophe in front of the formula in cell B1 (image 2) to have it display the formula. Note the formulas are slightly different since they point to different reference cells.
Also, here's a great reference for how the vlookup function works:
http://chandoo.org/wp/2012/03/30/comprehensive-guide-excel-vlookup/
Here is another solution that's closer to your adjusted question.
This solution still uses the vlookup formula. Instead of using it to associate a value on multiple rows, you can look-up a single value. (same function, different application)
Again, I'll point you to a great reference for how the vlookup function works:
http://chandoo.org/wp/2012/03/30/comprehensive-guide-excel-vlookup/

Resources