Excel: dynamically calculate range next to a searched up cell - excel

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

Related

How to Find the location of a value in a multi row/column Excel spreadsheet table?

How do I find either the cell address or preferably the row and column of the value 119, or any other number in the table below?
The table does not contain row or column titles, only the numbers as shown.
I am looking for a worksheet solution (formula) and not a VBA solution.
An Array Formula
This is an array formula and it has to be entered with control shift enter i.e. hold control shift and then press enter.
=MAX(IF(A1:J34=119,ROW(A1:J34)-ROW(A1)+1))
Remarks:
The value is searched by column i.e. A1, A2, ... B1, B2 ... i.e. if you had another 119 in cell D1 the result would still be 2, and if you had a 119 in cell c1 then the result would be
1.
For a column version just replace ROW with COLUMN:
=MAX(IF(A1:J34=119,COLUMN(A1:J34)-COLUMN(A1)+1))
Well, clunky and you can expand it, but it does work:
Row is separate to column but you could put them together in one cell, does depend on how you want to use the results, but you did not specify that so I have done this...
You could use a choose() function or a lookup table with vlookup() to change the column result to a letter...
Please try:
=MOD((K1-50),34)+1&" | "&1+(INT((K1-50)/34))
where K1 is your selected value.
Returns R | C. (Data in A1:J34 is not required.)
Below is a general purpose answer based on VBasic2008's answer.
I modified the formulas to utilize defined names so that the cell references do not have to be hard coded in the formulas. This way both the data table and row / column formulas can be relocated to anywhere on the spreadsheet. It works for both numerical AND text based data.
I also included the =ADDRESS() function to return the absolute reference of the look up value.
For illustration purposes, a step by step example for Data Set 1 is shown replacing the hard coded cell references with defined names.
The Data Set 2 section is the simplified version just using one defined for each the row and column look up value.
You can download an example spreadsheet here: Look_Up_a_Value_in_a_Table.xls
Thanks to all of you: Solar Mike, VBasic2008, and pnuts
Click on the image to enlarge.

How to report cell value to another cell on excel

I'm entering datas in A column of a table. According to the datas, I making sums from the yellow cell (actually this yellow cell is the high value of the A column). So all 10 cells, there is a sum until the end of datas.
I'm looking for automatically report the seven first grey cells (the sums)to another table. The problem is, according to the datas, high value is not at the same place so the sums are not to the same place too.
How can I do ?
Thank you for your help
MY ERROR :
And the message when I press ctrl maj enter in same time :
You might use this array formula in your report.
=INDEX($F:$F,SMALL(ROW($F$4:$F$117)+(100*(F$4:$F$117="")), ROW(F1)))&""
Bear in mind that, as an array formula, it must be confirmed with Control+Shift+Enter. Enter the formula in the row where you have Somme = 1, then copy down to 6. Note that Row(F1) is a counter. You have a similar counter (1 to 6) in F124:F130. Therefore you can replace ROW(F1) with $F124 (if that is where the "1" is) to make it easier to understand, perhaps.
The formula retrieves the value of the 1st, 2nd, 3rd etc non-blank cell in the range F4:F117. If those cells contain a formula they will be considered "blank" if their result equals "".
BTW, if you don't always have 113 results to evaluate you might consider giving a name to the range E4:E117. For example, if you name that range as "Results" then =SUM(Results) would be the same as =SUM($E$4:$E$117), but as you insert or delete rows within the named range the formula doesn't need to be amended. Use of a named range would simplify understanding your existing formula. You could do the same with column F.
Finally I find a solution to report the values from F to another table. As values positions are dependant of the MAX raw in E (every 10 cells) I make this formula :
For the first : INDEX(E4:F117;EQUIV(GRANDE.VALEUR($E$4:$E$117;1);$E$4:$E$117;0)+10;2)
For the second :
INDEX(E4:F117;EQUIV(GRANDE.VALEUR($E$4:$E$117;1);$E$4:$E$117;0)+20;2)
Etc...

Dynamic reference to the above cell

In my Excel worksheet, every 25 rows or so (this number is subject to change), a cell in column C contains a progressive number, identifying a set. Right now, there is a simple formula, e.g. in Cell 34:
= C9 + 1
When The number of rows above C34 changes, the formula updates automatically. No issue with that.
I am now experimenting with a macro that inserts a set in between two existing sets; therefore another number that should fit in the progression, and the following numbers should adapt.
I thought that formulas should change, to find the first number above the current cell and add +1.
Trying a solution from this link, I came up with the following formula:
=LOOKUP("z";$C$9:OFFSET(INDIRECT(ADDRESS(ROW();COLUMN()));-1;0))+1
It seems however that it only searches for text, giving a #N/Awhen there is no text and a #VALUE! when there is text; if I do not add the +1, it works fine.
I also tried
=LOOKUP(2;1/(C$9:C9<>"");C:C)
As explained in the link but all I get is 0
How do I modify these formulas to give me the expected result?
Assuming than the number of the first set is in A1,
enter this formula
=INDEX(A:A,MATCH(1E+100,OFFSET(A$1,,,ROW()-1)))+1
in the counting cells (A5,A10, A16 in the example):
Then you can insert rows for a new inserted set, for example:
When ypu copy the same formula into C10,
the set numbers update accordingly:
And you can fill the text elements of the set:

Excel find lower distinct value in list

I'm trying to find in a list the lowest unique value.
I tried to find out a way on google, but nothing seem to work like I want.
What i have :
John;5
Leon;7
Mark;5
Bob;3
Peter;3
Louis:4
Desired result: "4" because it's the lower unique value.
Suppose I add in the original list:
Alex;4
The new result is about to be "7" because it's the new lowest unique value.
my excel sheet :
Assuming your data is setup so that names are in column A and values are in column B so that it looks like this:
In cell D2 (or wherever you want the result), use this array formula (Note that array formulas must be confirmed with CTRLSHIFTENTER and not just ENTER):
=MIN(IF(COUNTIF(B2:B20,B2:B20)=1,B2:B20))
You'll know you've entered it as an array formula correctly because you'll see it surrounded by curly braces {=formula}in the formula bar. Do NOT add the curly braces manually.
You'll also notice that I have extra rows in there than just the used rows. Normally I'd suggest using a dynamic named range, but this works for now. So when you add the new line of Alex; 4, you get this:
And you can see the formula now has the new correct value of 7.
With data in columns A and B, in C1 enter:
=COUNTIF(B:B,B1)
and copy down. Then in another cell enter the array formula:
=MIN(IF(C:C=1,B:B))
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key.
To avoid speed problems, make the limits on the ranges as small as possible:
=MIN(IF(C1:C6=1,B1:B6))

Use string value from a cell to access worksheet of same name

I have 2 worksheets: Summary and SERVER-ONE.
In cell A5 on the Summary worksheet, I have added the value SERVER-ONE.
Next to it, in cell B5, I would like a formula that uses the value in A5 to display the value of G7 in the worksheet of the same name (SERVER-ONE).
I could manually use:
='SERVER-ONE'!G7
However I would like this to be dynamic, so I can easily add more worksheets.
I tried the obvious with no joy:
='A5'!G7
Any suggestions?
You can use the formula INDIRECT().
This basically takes a string and treats it as a reference. In your case, you would use:
=INDIRECT("'"&A5&"'!G7")
The double quotes are to show that what's inside are strings, and only A5 here is a reference.
You need INDIRECT function:
=INDIRECT("'"&A5&"'!G7")
not sure if you solved your question, but I found this worked to increment the row number upon dragging.
= INDIRECT("'"&$A$5&"'!$G"&7+B1)
Where B1 refers to an index number, starting at 0.
So if you copy-drag both the index cell and the cell with the indirect formula, you'll increment the indirect.
You could probably create a more elegant counter with the Index function too.
Hope this helps.
Here is a solution using INDIRECT, which if you drag the formula, it will pick up different cells from the target sheet accordingly. It uses R1C1 notation and is not limited to working only on columns A-Z.
=INDIRECT("'"&$A$5&"'!R"&ROW()&"C"&COLUMN(),FALSE)
This version picks up the value from the target cell corresponding to the cell where the formula is placed. For example, if you place the formula in 'Summary'!B5 then it will pick up the value from 'SERVER-ONE'!B5, not 'SERVER-ONE'!G7 as specified in the original question. But you could easily add in offsets to the row and column to achieve the desired mapping in any case.
By using the ROW() function I can drag this formula vertically. It can also be dragged horizontally since there is no $ before the D.
= INDIRECT("'"&D$2&"'!$B"&ROW())
My layout has sheet names as column headers (B2, C2, D2, etc.) and maps multiple row values from Column B in each sheet.
INDIRECT is the function you want to use. Like so:
=INDIRECT("'"&A5&"'!G7")
With INDIRECT you can build your formula as a text string.
Guess #user3010492 tested it but I used this with fixed cell A5 --> $A$5 and fixed element of G7 --> $G7
=INDIRECT("'"&$A$5&"'!$G7")
Also works nested nicely in other formula if you enclose it in brackets.
This will only work to column Z, but you can drag this horizontally and vertically.
=INDIRECT("'"&$D$2&"'!"&CHAR((COLUMN()+64))&ROW())

Resources