I am an occasional Excel user and stuck how to create a dynamic range.
After looking up a text in a table, how can I calculate the range next to this cell, up to the next empty row? Not using VBA.
Thanks for your help.
In H4, formula copied down :
=IFERROR(INDEX(INDEX(C:C,MATCH(F4,A:A,0)):C$1000,MATCH(G4,INDEX(B:B,MATCH(F4,A:A,0)):B$1000,0)),"")
Should you want a dynamic range,
Change C$1000 to INDEX(C:C,MATCH(9.9E+307,B:B)
and
Change B$1000 to INDEX(B:B,MATCH(9.9E+307,B:B))
Then
The H4 copied down formula become :
=IFERROR(INDEX(INDEX(C:C,MATCH(F4,A:A,0)):INDEX(C:C,MATCH(9.9E+307,B:B)),MATCH(G4,INDEX(B:B,MATCH(F4,A:A,0)):INDEX(B:B,MATCH(9.9E+307,B:B)),0)),"")
Edit :
As per Ron Rosenfeld's comment, "should B11 change to 24 and G4 change to 24"
The "Source Table" set up in Excel Table type for dynamic range growing purpose
and
The H4 formula change to :
=IFERROR(LOOKUP(9^9,Table1[price]/(LOOKUP(ROW(Table1[texture]),ROW(Table1[texture])/(Table1[texture]<>""),Table1[texture])=F4)/(Table1[length]=G4)),"")
Combining the Index() and Match() functions usually works well when using two conditions. However, you will need to fill out the entire column A with the "texture" list in order for the below formula to work.
=INDEX(<P1>, MATCH(TRUE, (<T1>=<T2>) + (<L1>=<L2>) > 1,0))
Where <P1> is your entire price column (ex. C2:C15)
Where <T1> is your entire texture column (ex. A2:A15)
Where <T2> is your texture lookup value cell
Where <L1> is your entire length column (ex. B2:B15)
Where <L2> is your length lookup value cell
Let's say that you input your texture value into cell F3, and your length value into cell F4. With the remaining columns remaining as they are in your image, you would use the following formula:
=INDEX(C2:C15, MATCH(TRUE, (A2:A15=F3) + (B2:B15=F4) > 1,0))
Now last time I had to use Index/Match I thought I had to place the formula into an array. However, the above seems to work without it.
If you notice that it's not working as expected, you can place into an array formula by clicking the cell that contains the formula, then clicking the formula box at the top. While in the formula box, simultaneously press Ctrl + Shift + Return. This should then place curly brackets around your entire formula if done properly, as such:
If you have O365 with the SEQUENCE function, you can use, for price:
=IF(G4="","",VLOOKUP(G4,INDEX($B:$C,SEQUENCE(MATCH(TRUE,ISBLANK(INDEX($B:$B,MATCH(F4,$A:$A,0)):INDEX(B:B,ROWS(B:B)-MATCH(F4,$A:$A,0))),0)-1,,MATCH(F4,$A:$A,0)),{1,2}),2,FALSE))
explanation:
get starting row:
MATCH(F4,$A:$A,0)
ending row will be the first blank row after the starting row:
MATCH(TRUE,ISBLANK(INDEX($B:$B,MATCH(F4,$A:$A,0)):INDEX(B:B,ROWS(B:B)-MATCH(F4,$A:$A,0))),0)
Construct the relevant array:
INDEX($B:$C,SEQUENCE(MATCH(TRUE,ISBLANK(INDEX($B:$B,MATCH(F4,$A:$A,0)):INDEX(B:B,ROWS(B:B)-MATCH(F4,$A:$A,0))),0)-1,,MATCH(F4,$A:$A,0)),{1,2})
The above might reduce (with wavy) to:
index(b:c,{9,10,11},{1,2}
Then it's just a matter of applying the VLOOKUP
A more understandable, but longer with more operations, formula available in O365 makes use of LET. The advantage is that one can use names which indicate what each section of the formula does.
For example:
=IF(G4="","",LET(startRow,MATCH(F4,$A:$A,0),numRows,MATCH(TRUE,ISBLANK(INDEX($B:$B,startRow):INDEX($B:$B,ROWS($B:$B)-startRow)),0)-1,
arr,INDEX($B:$C,SEQUENCE(numRows,,startRow),{1,2}),price,XLOOKUP(G4,INDEX(arr,0,1),INDEX(arr,0,2)),price))
Or, using VLOOKUP
=IF(G4="","",VLOOKUP(G4,LET(startRow,MATCH(F4,$A:$A,0),numRows,MATCH(TRUE,ISBLANK(INDEX($B:$B,startRow):INDEX($B:$B,ROWS($B:$B)-startRow)),0)-1,arr,INDEX($B:$C,SEQUENCE(numRows,,startRow),{1,2}),arr),2,FALSE))
Finally, for earlier versions of Excel, you can use this whopper where we replace the SEQUENCE function with a construct like: ROW(INDEX(A:A,firstRow):INDEX(A:A,lastRow))
=IF(G4="","",VLOOKUP(G4,INDEX($B:$C,ROW(INDEX($A:$A,MATCH(F4,$A:$A,0)):INDEX($A:$A,MATCH(F4,$A:$A,0)+MATCH(TRUE,INDEX($B:$B,MATCH(F4,$A:$A,0)):INDEX($B:$B,ROWS($B:$B))="",0)-2)),{1,2}),2,FALSE))
E.g. I want to check if array (B1:B10) concatenated with (C1:C10) contains the text in cell A1, and if it does, return "Detected".
Some background info:
1) When those 2 arrays are concatenated together, they should have same length as A1.
2) Arrays concatenated with equivalent range value e.g. B1 with C1, B2 with C2.
EDIT
Using BigBen's template below, I tried =IF((MATCH(LEFT(A1,3),B1:B10,0)=MATCH(RIGHT(A1,3),C1:C10,0)),"detected","")
and managed to get the desired result; however, it does not account for duplicates 'bar' within column C.
enter image description here
enter image description here
IIUC, you can use MATCH for this:
=IF(ISNUMBER(MATCH(A1,B1:B10&C1:C10,0)),"Detected","")
IMPORTANT: Note that depending on your version of Excel, you may need to enter the formula with Ctrl+Shift+Enter.
This is probably very brittle, but given the data outline in BigBen's answer, this array formula (needs to be confirmed with Ctrl+Shift+Enter) returns the expected result:
=IF(ISNUMBER(SEARCH(A1,TEXTJOIN("|",FALSE,B1:B10&C1:C10),1)),"Detected","")
It basically joins each value in column B with the corresponding value in column C, then checks to see if the key word is detected in the resulting string. It is also dependant on you having a version of Excel that has the TEXTJOIN function.
Here is a view of the formula evaluation:
*note, I trimmed the data down to only 5 records, but you get it...
I have a data set with range A4:S3365. My lookup value is A3 and I am trying to search or lookup the value in column E and return data on column A. however, multiple data in column A are assigned to the same lookup value in A3 and so when I do an index match function, it only returns the first value that it finds. It does not keep return other values in Column A that are also assigned to A3.
Can you help to fix this?
This is what I have tried so far:
INDEX(Tempxxl!$A$4:$A$3365,MATCH($A3,Tempxxl!$E$4:$E$3365,0))
When I run this code, I get the same value returned multiple times. I will like all the values in column A assigned to the lookup value in A3 to be listed out when i drag the formula down.
If you have the latest version of Excel including the function =TextJoin() then the following solution should work:
{=TEXTJOIN("|",TRUE,IF(Tempxxl!$E$4:$E$3365=$A3,Tempxxl!$A$4:$A$3365,""))}
Please note that this is an array formula and must be entered as such. That means that you should not enter the curved brackets but only everything inside the curved brackets and then press Ctrl + Shift + Enter. Excel will then add automatically the curved brackets.
I have searched the Net and tried multiple solution which never worked. You are my last hope.
I have a table like that:
NAMES.......... VALUES
A...........................4
A...........................1
B...........................4
B...........................3
B...........................2
B...........................1
C...........................4
C...........................3
As you can see, the first column has names only where the second one values.
Both Names and Values often repeat them self.
The idea is to TAG the names (first column) with the MIN value taken from the second column.
So the correct result should be:
NAMES.......... VALUES
A...........................1
B...........................1
C...........................3
I am trying to do that through Excel using the INDEX+Match formula where I am trying to add a MIN formula without success:
=MIN(INDEX($D$25:$D$36,MATCH(C25,$C$25:$C$36,0),1))
I have put the MIN everywhere but none seems to work. Which is the correct syntax and if this is not the right solution, which formula might do the job?
Thank you for your time and help
With data in column A and B, in C1 through C3 enter:ABC then in D1 enter the array formula:
=MIN(IF(A$1:A$100=C1,B$1:B$100,""))
and copy down:
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key. If this is done correctly, the formula will appear with curly braces around it in the Formula Bar.
If the data never changes, a Pivot Table is easier to implement.
Two non-array alternatives.
With the newer MINIFS function.
=minifs(d:d, c:c, c25)
Using INDEX in its array format but entered as a standard formula,
=min(index((d$25:d$36)+(c$25:c$36<>c25)*1e99, , ))
I currently have this:
=SUMPRODUCT(SUMIF(A:A;Index(List;;1);B:B))
Column A is a list of names, column B is a list of values for each names. The named range List has 2 columns, the first one are names and the second one are boolean values (0 or 1).
My formula actually works to return the sum of every column B values of its corresponding name in the A column IF that name is in the first column of my named range List. It works fine.
However, I would like to filter that to only include names from List that have the boolean value equal to 1 (ie. Index(List;;2) = 1.
How is this possible?
This is what I tried but it gives me a #REF! error:
=SUMPRODUCT(SUMIF(A:A;Index(List;;1)*Index(List;;2);B:B))
Probably best to switch to an array formula**:
=SUM(SUMIF(A:A,IF(INDEX(List,,2),INDEX(List,,1)),B:B))
**Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
Since your Named Range consists of discontinous ranges, when INDEXing it you will need to include INDEX's 4th parameter (area_num) in order to clarify which of the ranges ($B$2:$B$100 or $L$2:$W$100) you wish to refer to, e.g.:
=INDEX(List,60,1,**2**)
which will return the value in cell L61.
Regards