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))
In my excel file, I am trying to determine if a set of numbers is greater than the value of another cell.
I have written out an IF statement that only works sometimes depending on the range of the set of numbers. I have been able to replicate the problem but can't understand what is going wrong. I have included an example of my problem.
"B4" is equal to 2
"'Data Sheet'!A1:A10" is a set of 10 numbers from 1 to 10 inclusive.
My first statement (seen below) is working fine:
=IF(B4>'Data Sheet'!A1:A10,"Pass", "Fail")
which returns Fail, as expected.
However, when I change the statement to:
=IF(B4>'Data Sheet'!A6:A10,"Pass", "Fail")
It returns "#VALUE!".
Why does the range of values in the IF statement make a difference to whether it works or not?
Your formula is an array formula, and it is probably due to serendipity that your first formula is returning what you expect as an answer.
When you enter it into a cell as a non-array formula, which is what you are doing, it will return the value from the column A range that is in the same row as the formula.
Had you entered the first formula in Row 1, it would have returned "Pass" since it would be comparing B4 with A1.
If it is not in a row corresponding to a row in the range, it will return #VALUE.
If you confirm the formula as an array formula, by holding down ctrl + shift while hitting enter, then the formula will return an array of Pass;Fail depending on the relationship of B4 to each of the values in A1:A10. (or A6:A10). The visible value in a single cell will be the result of the first comparison.
So you will need to properly evaluate the array, in order to return whatever it is you want from the formula.
I'm not sure of exactly what you want.
If you want to determine if B4 is greater than any of the numbers in A1:A10, then try (entered normally):
If(B4 > MAX(A1:A10),"Pass","Fail")
If you want something else as a result, you will need to be more specific.
I am having trouble with an Excel-function.
On sheet A I want to get the value of a cell that is located x-columns to the right of cell F2.
X is a variable number and is determined by the value of cell A1. Currently, the value is 5.
=(OFFSET(sheetA!F2,0,sheetA!A1))
This formula works. However, I want to include this function into a MATCH and INDEX function that is located on another sheet (B).
I know that I can use the following formula to get value of $F$2
INDEX(sheetA!F:F,MATCH(sheetB!C4,sheetA!A:A,0))
Combining them, results in the following formula:
=INDEX((OFFSET(sheetA!F2,0,sheetA!A1)),MATCH(sheetB!C4,sheetA!A:A,0))
This formula generates a #REF!-value.
If I evaluate the formula, I see the following steps:
=INDEX((OFFSET(sheetA!$F$2,0,5)),MATCH(sheetB!C4,sheetA!A:A,0))
=INDEX((sheetA!$K$2),MATCH(sheetB!C4,sheetA!A:A,0))
=INDEX((sheetA!$K$2),MATCH("BTC",sheetA!A:A,0))
=#REF!
Why do I want to use MATCH and INDEX?
Because while the values on sheet A are "fixed", the values of sheetB!C4 are floating/variable. Therefore, I need to locate the correct row first. The correct column can be done with the offset-part.
Thank you for your help.
Try this
=INDEX((OFFSET(SheetA!F:F,0,SheetA!A1)),MATCH(SheetB!C4,SheetA!A:A,0))
Syntax of INDEX is
INDEX(array, row_num, [column_num])
where, array is range of cells. When you use =INDEX((OFFSET(sheetA!F2,0,sheetA!A1)),MATCH(sheetB!C4,sheetA!A:A,0)), (OFFSET(sheetA!F2,0,sheetA!A1)) returns sheetA!$K$2 which is a cell not a range.
Currently using the following forumlas to count the number of records in all of column Z that does not have #N/A but it does not work. All the rows in Column Z have a formula itself (Which is why some of them display #N/A, its a VLOOKUP).
=COUNTA(Z:Z)-SUM(IF(ISNA(Z:Z),1))
=SUMPRODUCT(--(TRIM(Z:Z)<>"#N/A"))
These return a "0" value which is not true, what am I doing incorrect?
If you are using Excel 2010 or later, to count non-error values you can use (regular formula)
=AGGREGATE(3,6,Z:Z)
No reason to use an array formula for this, you can just do something like
=COUNTIFS(Z:Z, "<>#N/A",Z:Z, "<>")
or
=COUNTA(Z:Z) - COUNTIF(Z:Z,"=#N/A")
The first one counts every nonblank, non #N/A cell. The second does what you're trying to do now and subtracts the total of #N/A cells from the total of every nonblank cell. Maybe using ISNA is technically more correct or faster, but this probably works just as well for most cases.
This array formula sums the cells of range Z:Z that are not NA's :
=SUM(IF(NOT(ISNA(Z:Z)),Z:Z)) Ctrl+Shift+Enter
This one (which is probably what you want) sums all but errors:
=SUM(IF(NOT(ISERROR(Z:Z)),Z:Z)) Ctrl+Shift+Enter
And another (simpler) one
=SUM(IFERROR(H:H, 0)) Ctrl+Shift+Enter
Are you entering it as an array formula? Press Ctrl-Shift-Enter instead of just enter. I think the first formula should work.
=COUNTA(Z:Z)-SUM(IF(ISNA(Z:Z),1))
I have this formula in excel, to return a row number:
=MATCH(INDIRECT(ADDRESS(ROW(),4)),DayOffRequests!$A$1:$A$100,0)
and it works just fine.
I would like to make a new name (DAYS_OFF_ROW) and assign it to this formula.
Here's what I did in the name manager:
But when I write this into a cell: =DAYS_OFF_ROW it says #VALUE! whereas when I write the same formula into the cell, it gives me the row number I am looking for.
Why is does it say #VALUE! and not the row number like the formula does?
First off Row() returns the row on which the cell resides. If you put Row() in indirect you will get an error since there is no cell for which Excel can find a Row(). So right off the bat, your formula is nonsense for a named range.
Second, even if there was some magic way for Excel to know which Row() you cared about here, Match doesn't return a range. Just a position in an array like "5" or "50". When you use a formula to define a named range, the result of the formula MUST be a range. So you could do another Indirect like =Indirect("A" & Match(foo,bar)) or something so that the result out of your formula actually refers to a range in your sheet.
It works if i set the name to this formula: =MATCH(!$D1,DayOffRequests!$A$1:$A$100,0)
Of course i have to be in field A1 when setting the name. Now its reference the fourth column and whichever row i am in.