Value lookup and rounding questions - excel

I have a cell with a value and I want to lookup that value in a defined range and then grab the closest value in the range that is larger than the lookup cell.
Example: Cell contains 37.24, Range has:
2.75
5.5
8.25
11
16.5
22
28
34
40
46
...
For this instance the formula should return 40 as the value. If the original field was 40.1 it would return 46.

If your 'cell' is A1 and the range of values in E3:E12, please try:
=IFERROR(VLOOKUP(A1,E3:E12,1,0),INDEX(E3:E12,MATCH(A1,E3:E12,1)+1))
This looks (with VLOOKUP) for an exact match and if that fails uses approximate MATCH to find the next lower value and then INDEX steps down one cell.

Related

Excel Index Match Formula last change

I've got a column U and a column L.
What I need to get is the value from column L when searched in column U.
Column L Column U
516 11
123 11
74 5
46 11
748 21
156 11
189 21
187 21
For example:
I want to search 21 in column U but I need to find the first value from the last change
(the number stays the same further in the column).
So if I want the value belonging to 21 I need to get 189.
I tried it with (thanks to Scott Craner):
=INDEX($L:$L,AGGREGATE(14,6,ROW($U$10:$U$500)/($U$10:$U$500=D2),1))
But this gets me the last 21 value so 187 as answer.
Does anybody know how to solve this?
You need to find the last row in column U with the value from D2 where the row immediately above it is not the same value.
=INDEX(L:L, AGGREGATE(14,6,ROW(U$10:U$500)/((U$10:U$500=D2)*(U$9:U$499<>D2)),1))
Now change U15 to be another 21. The result becomes,
For a dynamic number of values in columns L and U (starting in row 10), use,
=INDEX(L:L, AGGREGATE(14,6,ROW(U$10:INDEX(U:U, MATCH(1E+99, U:U)))/((U$10:INDEX(U:U, MATCH(1E+99, U:U))=D2)*(U$9:INDEX(U:U, MATCH(1E+99, U:U)-1)<>D2)),1))
If I understand you correctly, I believe this accomplishes the task:
=INDEX($L:$L,MATCH(INDEX($L:$L,AGGREGATE(14,6,ROW($U$9:INDIRECT("$U$"&MATCH(INDEX($L:$L,AGGREGATE(14,6,ROW($U$10:$U$500)/($U$10:$U$500=D2),1)),$L:$L,0)))/($U$9:INDIRECT("$U$"&MATCH(INDEX($L:$L,AGGREGATE(14,6,ROW($U$10:$U$500)/($U$10:$U$500=D2),1)),$L:$L,0))<>D2),1)),$L:$L,0)+1)
It builds on Scott's concept, and finds the 187, then limits the search arrays to the row where it finds 187, and finds the last row that does not have the number you are searching for (21). Then it indexes the first row after that, which will be the first match in the last series.

Output range of cell value in excel

I need to compute the range of a given cell in excel. For example, if the cell is like below,
Val
---
25
23
18
52
66
I need a formula to just find which range it belongs to. the ranges can be in intervals of 5 .. like 0-5,5-10,10-15 and so on. So desired output is
Val Range
-------------
25 21-25
23 21-25
18 16-20
52 51-55
66 66-70
Assuming A1 holds the value 25, then put this formula in A2:
=TEXT(CEILING(A1/5,1)*5-4,"0")&" - "&TEXT(CEILING(A1/5,1)*5,"0")
Copy it down to other rows as required

How to use index and match concept to retrieve values from 2nd row and 3rd column or 1st row and 4th column and so on

Jan Feb Mar Apr May
1 10 110 101 11 90
2 20 111 102 12 91
3 30 112 103 13 92
4 40 113 104 14 93
5 50 114 105 15 94
How to use index and match concept to retrieve values from 2nd row and 3rd column or 1st row and 4th column and so on
If you wanted to match cell $B$2 (Row 2, Column "February") you could use the following formula:
INDEX(B1:B5, MATCH(91, E1:E5, 0))
This would give the value 111, which is the value of $B$2
The INDEX function in Excel takes a range (B1:B5) and an index into that range, and returns the value. In an INDEX MATCH, the index used is actually a call to the MATCH function. Here, I obtained an index of 2 when MATCHing the value 91 in the range E1:E5.
In English you might read this call as saying "Find the value in the range B1 to B5 whose index is the same as the value 91 in the range E1 to E5."
If the months are in B1:F1, row labels in A2:A6 and main body of the table in B2:F6 then you can get the value at the intersection of the nth row and kth column of B2:F6 using this formula
=INDEX(B2:F6,n,k)
As per Tim's answer you can derive the n and k values using MATCH functions based on the values in the column headers and row labels, e.g. matching "Apr" and 4 will give you the value at the intersection, i.e. 14
and the formula would look like this
=INDEX(B2:F6,MATCH(4,A2:A6,0),MATCH("feb",B1:F1,0))
see here for more

Index/Match values from a column using a grid of a different length (Excel 2010)

I am trying to index match values from a long column to a grid of a different length. It looks like this
Word Number Column X Column Y Column Z
This 55 55 33 12
is 62 62 42 18
The 78 78 31 24
42
31
12
18
24
33
The grid (Column X,Y,Z) contains all the values from the Number Column. What I am trying to do is basically index the "Word" column, using a value from the "Number" Column, and looking it up in the value array of X Y Z.
Example (because this is confusing):
Input the Value 33 from the Number column, look for the value in the columns XYZ, and then return the Word "This".
Input the Value 18 from the number column, look for the value in columns XYZ, return the word "is"
etc...
Any help would be very much appreciated!
there is a quicker way and shorter formula to do this:
=IFERROR(INDEX(A:A,IFERROR(MATCH(B2,C:C,0),IFERROR(MATCH(B2,D:D,0),MATCH(B2,E:E,0))),1),"not found")
paste that into, any column really, into row 2 and drag down, it will return the words you require, if value not found it will return "not found"
Here is your spreadsheet starting at cell A1 (without your headers):
A B C D E
1 This 55 55 33 12
2 is 62 62 42 18
3 The 78 45 31 24
4 42
5 31
6 12
7 18
8 24
9 33
10
11 Input: 24
12 Output: The
Copy this into cell C10, and drag the formula across to cell E10:
=IF(ISERROR(IF(ISERROR(IF(ISERROR(MATCH($B$11,C1:C3,0)),"",CONCATENATE("A",MATCH($B$11,C1:C3,0)))),"",INDIRECT(IF(ISERROR(MATCH($B$11,C1:C3,0)),"",CONCATENATE("A",MATCH($B$11,C1:C3,0)))))),"",IF(ISERROR(IF(ISERROR(MATCH($B$11,C1:C3,0)),"",CONCATENATE("A",MATCH($B$11,C1:C3,0)))),"",INDIRECT(IF(ISERROR(MATCH($B$11,C1:C3,0)),"",CONCATENATE("A",MATCH($B$11,C1:C3,0))))))
Copy this to the "output" cell B12 and use cell B11 as your "input":
=CONCATENATE(C10,D10,E10)
VIOLA!!! You're done!
Proof:
The MATCH() function will look for your value in an array (the range). If it finds it, it returns the index of that array (indexed at 1), otherwise it throws an error. Be sure to set the 3rd argument to "0" so that it only looks for EXACT matches.
Paste this into C14:
=MATCH($B$11,C1:C3,0)
Next, we check if the MATCH() function did indeed throw an error. Paste this into C15:
=IF(ISERROR(C14),"",C14)
Now we have the row number of our matched value, so we will use the CONCATENATE() function to join it to our "word column", A, for use in the next step. Paste this into C16:
=CONCATENATE("A",C15)
Using that string from above, use the INDIRECT() function to turn it into an actual cell reference. Paste this into C17:
=INDIRECT(C16)
And finally, check if a legitimate cell reference was created. If so, return the word, otherwise return "". Paste this into C18:
=IF(ISERROR(C17),"",C17)
Lastly, drag the formulas from C14:C18 to E14:E18, and concatenate the results. The cells in row 18 should match the cells in row 10.
Hope this helps :)

Retrieve excel row value by checking if value within range of 2 columns

Any idea for an excel formula that should accept an input and return the value of the relevant row in Price column if the value entered is greater than the LowerRange column but lower than the UpperRange column.
i.e. input of 6 would return 5, input of 18 would return 10, input of 52 would return 30.
LowerRange UpperRange Price
1 10 5
11 20 10
21 30 15
31 40 20
41 50 25
51 60 30
InputCell:
InputFormula:
Use VLOOKUP(lookup_value, table_array, col_index_num, [range_lookup]) with range_lookup set to TRUE
From Excel help file:
If range_lookup is either TRUE or is omitted, an exact or approximate match is returned. If an exact match is not found, the next largest value that is less than lookup_value is returned.
If range_lookup is either TRUE or is omitted, the values in the first column of table_array must be placed in ascending sort order; otherwise, VLOOKUP might not return the correct value.
So, for your data use =VLOOKUP(B10,$A$2:$C$8,3,1) where value to look up is in B10 (add a value of 61 to col A and =NA() to col C to the end of the data to handle inputs > 60)

Resources