I am using the following formula to return the data in a cell from looking up a row number.
=INDIRECT("Sheet2!R"&SUMPRODUCT(--(Sheet2!S:S=Sheet3!D3),ROW(Sheet2!R:R)))
The sumproduct formula looks at the value in cell D3 and returns which row it is found on in Sheet2. When there are more than one cells with the value in D3, the row numbers get added together. How can I get it to return only the first instance if there is more than one cell with the lookup value? I think I need rank or something, but am a little lost.
First INDIRECT is volatile and should be replaced with INDEX.
Second use AGGREGATE to return the lowest row number
=INDEX(Sheet2!R:R,AGGREGATE(15,7,ROW(Sheet2!S:S)/(Sheet2!S:S=Sheet3!D3),1))
Note: I left the full column References, but it is better practice to limit both Sheet2!S:S references to that of just the data set. It will speed up the calculations.
Related
On Sheet2 I am trying to sum the values in a row of a range on Sheet1 over a dynamic range of columns based on a lookup value for the from column and a fixed variable for how many columns to right of that lookup value for the to column.
I am using INDEX-MATCH to find the from cell based on certain reference, INDEX-MATCH with a reference added to the column lookup to find the to column, and CELL to get the position rather than value of the results.
What I have is the following:
=SUM(
CELL("address",
INDEX(Sheet1!$B$4:$BA$36,MATCH($A$1,Sheet1!$A$4:$A$36),MATCH(D$3,Sheet1!$B$3:$BA$3,0)))
&":"&
CELL("address",
INDEX(Sheet1!$B$4:$BA$36,MATCH($A$1,Sheet1!$A$4:$A$36),MATCH(D$3,Sheet1!$B$3:$BA$3,0)+'Control Panel'!$C$2)))
Control Panel!$C$2 is my variable for how many columns to the right of the from column I want the to column to be.
Obviously, this is not working. I suspect it's because the concatenated text in the SUM() reference the full file name rather than 'Sheet1'![from]:[to]. Not sure if this is the case, but also can't figure out how to get just the A1 cell position for the to.
Any ideas how I can get this to work?
Figured it out:
=SUM(INDEX(Sheet1!$B$4:$BA$36,MATCH($A$1,Sheet1!$A$4:$A$36),MATCH(D$3,Sheet1!$B$3:$BA$3,0))):INDEX(Sheet1!$B$4:$BA$36,MATCH($A$1,Sheet1!$A$4:$A$36),MATCH(D$3,Sheet1!$B$3:$BA$3,0)+'Control Panel'!$C$2))
Literally just needed a colon between the two index-matches. Still not sure why this works, as the index-match should return a value.
I would like to return the sum of all values that are directly below a look up value "Pre173RB" in a single column.
First I used index and match but this is limited to only finding the first value "8".
=INDEX(B:B,MATCH(E1,B:B,0)+1,1)
I then attempted to incorporate the above formula into the repeating sequence below. The formula returned the first value in the column "30". The desired return is "18".
=INDEX(B:B, SMALL(IF(ISNUMBER(MATCH(E$1,B:B,0)+1), MATCH(ROW(B:B), ROW(B:B)), ""),ROWS(A$1:A1)))
I've attempted to use sumif in the above formula as well but errors return.
Any assistance is appreciated. I am probably complicating the formula.
=SUMIFS(B2:B26,B1:B25,E1)
Note that the sum range is offset one row versus the condition range.
I have a column which is a dynamic named range:
A
A
B
C
A
How can I apply a MATCH or other formula which returns the row or cell address of all A values in the dynamic named range?
A dynamic named range is used so all row or address of A values can automatically appear as a spill rather than having to drag down the formula.
I have seen numerous formulas in this structure:
=INDEX($B$2:$B$8, SMALL(IF($A$11=$A$2:$A$8, ROW($A$2:$A$8)-ROW($A$2)+1), ROW(1:1)))
However, most of these seem to return the first instance (row or cell address of the first match) and requires the formula to be dragged down manually rather than a spill, which is more preferable.
Any help will be greatly appreciated.
Use FILTER:
=FILTER(ROW(A1:A5),A1:A5=C1)
This will return the Row number everywhere they match.
From there it is pretty easy to include that in INDEX:
=INDEX(B:B,FILTER(ROW(A1:A5),A1:A5=C1))
If you do the full column in the index, you do not need the ROW($A$2:$A$8)-ROW($A$2)+1 as returning the actual row instead of relative works just fine.
Try something like =SORT(ROW($A$1:$A$5)/($A$1:$A$5=$C$1)). This will get you the matches of a value in C1 with a spill formula, leaving behind #DIV/0 errors
See example below:
Other answers that you might be able to take ideas from are here: Match Exact Row Number of Nth Largest Value In Data With Duplicates
You could be thinking of:
=SMALL(IFERROR(ROW(A1:A5)*MATCH(A1:A5,C1,0),FALSE),ROW(A1:INDEX(A:A,COUNTIF(A1:A5,C1),)))
Where your data start in A1 and your compare value is in C1.
If you have Excel 365, this is easier:
=INDEX(SORT(ROW(A1:A5)*MATCH(A1:A5,C1,0)),SEQUENCE(COUNTIF(A1:A5,C1)))
or better yet:
=LET( dataRange, A1:A5,
compareTo, C1,
INDEX(SORT(ROW(dataRange)*MATCH(dataRange,compareTo,0)),SEQUENCE(COUNTIF(dataRange,compareTo))) )
I am trying to obtain the value of a cell that is in a different sheet, from a formula that returns the value of the row where it finds a match.
Basically, what I'm trying to imitate is:
=Sheet!Column Row
But as follows
=Sheet!Column Formula (Which returns the row that meets the conditions of the formula)
The problem is that I tried concatenating the name of the sheet, the column and the result of the formula (row), which works, since I get, for example:
=Risks!K3
But that's all, I get a kind of string and in reality I would need that result to also be calculated by excel and return, precisely, the value of cell K3.
Is there any way to solve it?
Use INDEX:
=INDEX(Risks!K:K,formulathatreturns3)
I was not sure how to really create the question...
But the problem I am having is this: I have a list (in rows) that relate to a regulatory document, and after trying to create some sort of for loop or elaborate VLookUp/Index formula, I'm requesting help.
For example:
Now I want to use the rows to find the corresponding section in the document. I've already extracted and formatted the compliance document so it is in excel format.
So what I really need is this: a formula or VBA script that can
1. take the compliance number (for example 1A-1 which exist in Cell A3) and go find a cell (in single column D) that has JUST 1A-1, not 1A-1.1, not 1A-1.1.2, etc. and return it to the adjacent cell to 1A-1, for example.
Many thanks ahead of time... I am so lost!! :/
VLOOKUP vs INDEX/MATCH
You can do the 'lookup' two ways (that I'm aware of):
Using VLOOKUP:
The B3 cell contains your formula
=IF(ISERROR(VLOOKUP(A3,C:D,2,FALSE)),"",VLOOKUP(A3,C:D,2,FALSE))
where 'FALSE' is indicating there has to be an exact match and the data doesn't have to be sorted.
Using INDEX with MATCH:
The F3 cell contains the Index/Match formula
=IF(ISERROR(MATCH(A3,C:C,0)),"",INDEX(D:D,MATCH(A3,C:C,0)))
where '0' is indicating there has to be an exact match and the data doesn't have to be sorted.
INDEX/MATCH preferable!?
The MATCH function finds the position (row number if whole column is used) of the found match. This way (there's another) of using the INDEX function uses exactly this found match to return a cell's value in that position (row) in ANY specified column range (column). So they are the ideal combination.
With the VLOOKUP function you have to additionally specify the column index (range_lookup) of a range which could get complicated when the columns aren't adjacent as in this case. Most importantly, the function doesn't work if the lookup data is to the right of the match data.
VLOOKUP NOT WORKING! INDEX/MATCH STILL WORKING!
try this formula
The formula in cells
B2: =INDEX(E:E,MATCH(A2,F:F,0))
C2: =INDEX(G:G,MATCH(A2,F:F,0))
MATCH(A2,F:F,0) is finding Cell A2 in column F (0 means it will find
exact match) and will return the first row number when it would find that
INDEX(E:E,MATCH(A2,F:F,0)) will return contents of column E where row number is returned by the Match formula