vlookup with approximate

lezawang

Well-known Member
Joined
Mar 27, 2016
Messages
1,805
Office Version
  1. 2016
Platform
  1. Windows
Hi
I use vlookup to find the grade of each student (last argument is TRUE). My question why the grade table "has to" be sorted from smallest to the largest otherwise vlookup wont work. It wont work if the table was like this


90a
70b
60c
50d
0f

<colgroup><col width="64" span="2" style="width:48pt"> </colgroup><tbody>
</tbody>

Below, it will work because the grade table sorted from smallest to the largest

nametesttesttestaveragegrade
john118303528f
alex165787673b0f
mary118791537f50d
david190909993a60c
sarah161944567c70b
john22010010073b90a
alex230263731f

<colgroup><col width="64" span="9" style="width:48pt"> </colgroup><tbody>
</tbody>
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
A lot of these questions on functions and how they work can be found with a simple Google search of the function.
See here: https://www.extendoffice.com/documents/excel/2443-excel-vlookup-exact-approximate-match.html#a2

Note the second and third items:
[FONT=&quot]2. The approximate match returns the next largest value that is less than your specific lookup value.[/FONT]
[FONT=&quot]3. To use the vlookup function to get an approximate match value, your first column in the table must be sorted in ascending order, otherwise it will return a wrong result.[/FONT]
I believe it needs to be that way because it looks for the first value that is larger than the one you are looking up, then goes to the previous record (the row just above it).
 
Upvote 0
Vlookup approximate match splits the data and looks at the middle value. It uses this to pick which half of the data to look in to find the lookup value.

for example

Book1
BCDE
25700100A
26300B
27200C
28900D
2999E
30300F
31700G
32
33C
Sheet1
Cell Formulas
RangeFormula
D33=VLOOKUP(B25,D25:E31,2)


Vlookup will compare 700 to 900 and conclude that the lookup values must be in the top half of values since 700 is less then 900. If you were looking up 1,000 it would look at the bottom half since it is greater then 900.

Exact match vlookup does not need to be sorted because it works differently.
 
Upvote 0

Forum statistics

Threads
1,214,956
Messages
6,122,465
Members
449,085
Latest member
ExcelError

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top