edubun
English
1 / 21

6 / 6 · Basic

Looking things up with VLOOKUP

Leave out the last argument of VLOOKUP and both Excel and Google Sheets use an approximate match. Google recommends typing FALSE.

Jump to the 11 practice questions

You will learn

  • Look up a code with an exact match
  • Look up a band with an approximate match
  • Read #N/A, #REF! and #VALUE! from VLOOKUP

Before this: AND, OR and nested IF

1Explain

A price list with codes

A shop keeps its prices in a small table: codes in A2:A5, item names in B2:B5, prices in C2:C5. At the till, someone types a code and wants the price. That is VLOOKUP's job. It finds a value in the first column of a table and returns something from the same row. Microsoft lists the four pieces it needs: the value to look up, the range it is in, the column number in that range that holds the answer, and whether you want an approximate (TRUE) or exact (FALSE) match.

2Explain

First column, count from 1

Two rules cause most of the trouble. First, the value must be in the first column of the range, and the answer must be to its right. VLOOKUP never looks left, so if the codes are in column B, the range has to start at B. Second, the column number counts from the first column of the range, not from column A of the sheet; in B2:D9, B is 1, C is 2 and D is 3. Both help pages give the same advice for copied formulas too. Make the range absolute, as in $A$2:$C$5, so it doesn't slide when filled down.

3Problem

Code 103

Codes 101, 103, 104, 107 with items Apple, Banana, Orange, Pear in A2:B5. What does =VLOOKUP(103, A2:B5, 2, FALSE) return?

Hint

Row of 103, second column.

Solution

Answer: Banana

103 is in the second row; column 2 of the range holds Banana.

4Problem

Column E in C2:F20

The range is C2:F20. What column number returns values from column E?

Hint

C is 1, D is 2.

Solution

Answer: 3

Count from the range: C is 1, D is 2, E is 3.

5Problem

$A$2:$C$5

Why should the table range be written as $A$2:$C$5?

Hint

Fill down and watch the range.

Solution

Answer: So it does not slide when the formula is filled down

Both help pages recommend an absolute range for copied lookups.

6Explain

When the code isn't on the list

With FALSE, VLOOKUP looks for exactly the value you gave and returns the first row that matches. No match gives #N/A. A column number larger than the number of columns in the range gives #REF!, and one below 1 gives #VALUE!. Text lookups ignore case but not spaces: Google's help points out that " Apple", "Apple " and "Apple" are three different values. A number stored as text differs from the number too, so a code typed as '104 is not found by 104.

7Problem

Code 102, exact

Same table. What does =VLOOKUP(102, A2:B5, 2, FALSE) return?

Hint

102 is not on the list.

Solution

Answer: #N/A

Exact match, and 102 is not in the first column.

8Problem

Column 3 of a 2-column range

Same table. What does =VLOOKUP(103, A2:B5, 3, FALSE) return?

Hint

There is no third column.

Solution

Answer: #REF!

The range has only 2 columns, so column 3 does not exist.

9Explore

Wildcards and IFNA

With exact match, the wildcards ? and * work in both programs. ? stands for any one character and * for any run of characters, so "Ora*" finds Orange. When #N/A is a normal outcome, such as a code not yet on the price list, wrap the lookup in IFNA, which both programs have: =IFNA(VLOOKUP(E2, $A$2:$C$5, 3, FALSE), "not found"). IFERROR also works.

Loading

Drag to turn. Scroll or pinch to zoom.

After the tasks, type 102 into E2: exact match gives #N/A. Then change the column number to 4 and read the #REF! explanation.

10Problem

IFNA

Items are in B2:B5 and prices in C2:C5. What does =IFNA(VLOOKUP("Pencil", B2:C5, 2, FALSE), "not found") return?

Hint

Pencil is not on the list.

Solution

Answer: not found

Pencil is not in the list, so VLOOKUP gives #N/A and IFNA replaces it.

11Explore

Looking up a band instead of an exact code

TRUE, or no fourth argument at all, gives an approximate match, the default in both programs. Google's help describes the search: it runs down the first column until it finds a value larger than the search key, then stops on the row before. That suits bands. In a grade table with 0, 60, 70, 80 and 90 in the first column, a score of 85 runs past 80, meets 90, and returns B from the 80 row. The first column must be sorted from smallest to largest, and a value below the first row returns #N/A.

An approximate match keeps the last row whose first value is not larger than the score. Below the first row there is nothing, so #N/A.

Score
const table = [[0, "F"], [60, "D"], [70, "C"], [80, "B"], [90, "A"]];
const score = 85;
let found = "#N/A";
for (const row of table) if (row[0] <= score) found = row[1];
console.log(found);
Output
B

12Problem

85 in the grade table

Grade table: 0 F, 60 D, 70 C, 80 B, 90 A. What does an approximate VLOOKUP return for 85?

Hint

The last band that is not above 85.

Solution

Answer: B

85 passes 80, meets 90, and steps back to the 80 row.

13Problem

Exactly 90

Same table. What does it return for exactly 90?

Hint

90 is not larger than 90.

Solution

Answer: A

90 is not larger than 90, so the 90 row is the last one it can use.

14Problem

Code 102, approximate

Same table. What does =VLOOKUP(102, A2:B5, 2, TRUE) return?

Hint

The row before the first larger code.

Solution

Answer: Apple

Approximate: it passes 101, meets 103 which is larger, and steps back to 101.

15Problem

No fourth argument

What happens when the fourth argument is left out?

Hint

The default in both programs.

Solution

Answer: Approximate match in both programs

range_lookup and is_sorted both default to TRUE.

16Explore

Practice in the grid

Loading

Drag to turn. Scroll or pinch to zoom.

The same grade scale as the nested IF, kept in cells. Swap two rows of the table afterwards and the panel warns that the first column is no longer sorted.
Microsoft ExcelGoogle Sheets
Name of the 4th argumentrange_lookupis_sorted
Default when left outTRUE (approximate)TRUE (approximate)
Advice in the help pagesort the first column, or use FALSEFALSE is recommended
XLOOKUPMicrosoft 365 and Excel 2021 onward; not in 2016 or 2019available
Unreadable formularefused with a message#ERROR!
Circular referencewarning, then 0 or the last value#REF!
ROUND without digitsnot acceptedrounds to a whole number
Arguments per functionup to 255any number

17Explain

XLOOKUP

Both programs now also have XLOOKUP. It takes a lookup range and a separate result range, so the answer may sit to the left, and it uses an exact match unless told otherwise. Microsoft notes that XLOOKUP is not available in Excel 2016 or Excel 2019, so a file that must open in those versions should stay with VLOOKUP. The table above collects the differences between the two programs that this course has met.

18Problem

Versions without XLOOKUP

Which Excel versions do not have XLOOKUP?

Hint

Two older versions.

Solution

Answer: Excel 2016 and Excel 2019

Microsoft's XLOOKUP page: not available in Excel 2016 and Excel 2019.

19Practice

VLOOKUP in JavaScript

Finish vlookup(value, table, col, approx): with approx false, return column col (counting from 1) of the row whose first value equals value, or "#N/A". With approx true, use the last row whose first value is not larger than value. A col beyond the row gives "#REF!".

Expected output
Banana
#N/A
Apple
0.8
#REF!
Your code
const table = [
  [101, "Apple", 1.5],
  [103, "Banana", 0.5],
  [104, "Orange", 1.01],
  [107, "Pear", 0.8],
];
function vlookup(value, table, col, approx) {
  let hit = null;
  if (hit === null) return "#N/A";
  return hit[col - 1];
}
console.log(vlookup(103, table, 2, false));
console.log(vlookup(102, table, 2, false));
console.log(vlookup(102, table, 2, true));
console.log(vlookup(107, table, 3, true));
console.log(vlookup(103, table, 4, false));
Hint

Columns count from 1 but arrays from 0, so use hit[col - 1].

A solution
const table = [
  [101, "Apple", 1.5],
  [103, "Banana", 0.5],
  [104, "Orange", 1.01],
  [107, "Pear", 0.8],
];
function vlookup(value, table, col, approx) {
  if (col > table[0].length) return "#REF!";
  let hit = null;
  for (const row of table) {
    if (approx ? row[0] <= value : row[0] === value) {
      hit = row;
      if (!approx) break;
    }
  }
  if (hit === null) return "#N/A";
  return hit[col - 1];
}
console.log(vlookup(103, table, 2, false));
console.log(vlookup(102, table, 2, false));
console.log(vlookup(102, table, 2, true));
console.log(vlookup(107, table, 3, true));
console.log(vlookup(103, table, 4, false));

20Explain

Common mistakes

  • Leaving out FALSE when looking up a code.

    The default is approximate match, so a code that isn't on the list can come back with the price from the row above it instead of #N/A.

  • Counting the column number from column A of the sheet.

    It counts from the first column of the range. With C2:F20, column E is 3, not 5.

  • Filling a lookup down without $ on the range.

    A2:C5 slides to A3:C6, A4:C7 and so on, and lower rows stop finding codes near the top of the table.

  • Wrapping every lookup in IFERROR.

    It hides a #REF! from a wrong column number as well as the expected #N/A. IFNA hides only #N/A.

21

Summary

  • VLOOKUP(value, range, column number, FALSE) for an exact match.
  • The value must be in the first column; the column number counts from the range.
  • TRUE (or nothing) is approximate: the first column must be sorted, and it returns the last row not larger than the value.
  • Use an absolute range, IFNA for expected #N/A, and FALSE unless you mean bands.

Back to the courseSpreadsheet formulas
Full text · The whole lesson as one text

A price list with codes

A shop keeps its prices in a small table: codes in A2:A5, item names in B2:B5, prices in C2:C5. At the till, someone types a code and wants the price. That is VLOOKUP's job. It finds a value in the first column of a table and returns something from the same row. Microsoft lists the four pieces it needs: the value to look up, the range it is in, the column number in that range that holds the answer, and whether you want an approximate (TRUE) or exact (FALSE) match. =VLOOKUP(104, A2:C5, 3, FALSE) finds 104 in column A and returns the price from the third column of the range.

Two rules cause most of the trouble. First, the value must be in the first column of the range, and the answer must be to its right. VLOOKUP never looks left, so if the codes are in column B, the range has to start at B. Second, the column number counts from the first column of the range, not from column A of the sheet; in B2:D9, B is 1, C is 2 and D is 3. Both help pages give the same advice for copied formulas too. Make the range absolute, as in $A$2:$C$5, so it doesn't slide when filled down.

When the code isn't on the list

With FALSE, VLOOKUP looks for exactly the value you gave and returns the first row that matches. No match gives #N/A. A column number larger than the number of columns in the range gives #REF!, and one below 1 gives #VALUE!. Text lookups ignore case but not spaces: Google's help points out that " Apple", "Apple " and "Apple" are three different values. A number stored as text differs from the number too, so a code typed as '104 is not found by 104.

With exact match, the wildcards ? and * work in both programs. ? stands for any one character and * for any run of characters, so "Ora*" finds Orange. When #N/A is a normal outcome, such as a code not yet on the price list, wrap the lookup in IFNA, which both programs have: =IFNA(VLOOKUP(E2, $A$2:$C$5, 3, FALSE), "not found"). IFERROR also works. It hides every kind of error, though, including a wrong column number you would want to see, and Microsoft's #VALUE! page warns about IFERROR for the same reason.

After the tasks, type 102 into E2: exact match gives #N/A. Then change the column number to 4 and read the #REF! explanation.

Looking up a band instead of an exact code

TRUE, or no fourth argument at all, gives an approximate match, the default in both programs. Google's help describes the search: it runs down the first column until it finds a value larger than the search key, then stops on the row before. That suits bands. In a grade table with 0, 60, 70, 80 and 90 in the first column, a score of 85 runs past 80, meets 90, and returns B from the 80 row. The first column must be sorted from smallest to largest, and a value below the first row returns #N/A. On an unsorted column the answer can't be trusted, which is why Google recommends FALSE unless you mean a range.

The same grade scale as the nested IF, kept in cells. Swap two rows of the table afterwards and the panel warns that the first column is no longer sorted.
Microsoft ExcelGoogle Sheets
Name of the 4th argumentrange_lookupis_sorted
Default when left outTRUE (approximate)TRUE (approximate)
Advice in the help pagesort the first column, or use FALSEFALSE is recommended
XLOOKUPMicrosoft 365 and Excel 2021 onward; not in 2016 or 2019available
Unreadable formularefused with a message#ERROR!
Circular referencewarning, then 0 or the last value#REF!
ROUND without digitsnot acceptedrounds to a whole number
Arguments per functionup to 255any number

Both programs now also have XLOOKUP. It takes a lookup range and a separate result range, so the answer may sit to the left, and it uses an exact match unless told otherwise. Microsoft notes that XLOOKUP is not available in Excel 2016 or Excel 2019, so a file that must open in those versions should stay with VLOOKUP. The table above collects the differences between the two programs that this course has met.

Common mistakes
  • Leaving out FALSE when looking up a code. The default is approximate match, so a code that isn't on the list can come back with the price from the row above it instead of #N/A.
  • Counting the column number from column A of the sheet. It counts from the first column of the range. With C2:F20, column E is 3, not 5.
  • Filling a lookup down without $ on the range. A2:C5 slides to A3:C6, A4:C7 and so on, and lower rows stop finding codes near the top of the table.
  • Wrapping every lookup in IFERROR. It hides a #REF! from a wrong column number as well as the expected #N/A. IFNA hides only #N/A.
Teacher's noteVLOOKUP has four arguments, and learners tend to lose track of the third and fourth. Have them say the four pieces aloud for every formula they write. Teach FALSE first and treat approximate match as a separate lesson with a band table, so the two ideas don't blur. Then break the lab on purpose: a missing code, a column number that's too big, a code with a trailing space. An error message is far easier to remember once you have caused it by hand. XLOOKUP is worth a mention if everyone uses Microsoft 365 or Sheets.
Key points
  • VLOOKUP(value, range, column number, FALSE) for an exact match.
  • The value must be in the first column; the column number counts from the range.
  • TRUE (or nothing) is approximate: the first column must be sorted, and it returns the last row not larger than the value.
  • Use an absolute range, IFNA for expected #N/A, and FALSE unless you mean bands.

Practice questions from Looking things up with VLOOKUP on edubun

Embed this quiz

Free to embed. Please keep the credit line.

Sources for this course (19)
  • Microsoft Support, "Switch between relative, absolute, and mixed references" (support.microsoft.com/en-us/office/dfec08cd-ae65-4f56-839e-5f0d8d0baca9: $ before column and row, F4 to switch, copying two down and two right: $A$1 stays, A$1 to C$1, $A1 to $A3, A1 to C3)
  • Microsoft Support, "AVERAGE function" (support.microsoft.com/en-us/office/047bac88-d466-426c-a32b-8f33eb960cf6: text, logical values and empty cells in a reference ignored, zeros included; 10, 7, 9, 27, 2 gives 11, with 5 gives 10; mean 5, median 4, mode 3 for 2 3 3 5 7 10)
  • Microsoft Support, "COUNT function" (support.microsoft.com/en-us/office/a59cd7fc-b623-4d93-87a4-d23bf411294c: only numbers counted, dates count, errors and text do not)
  • Microsoft Support, "ROUND function" (support.microsoft.com/en-us/office/c018c5d8-40fb-4053-90b1-b3e7f61a213c: num_digits required; 2.15 to 2.2, -1.475 to -1.48, 626.3 to 1000, 1.98 to 0, -50.55 to -100)
  • Microsoft Support, "IF function" (support.microsoft.com/en-us/office/69aed7c9-4e8a-4755-a9bc-aa8bbff73be2: value_if_false optional, text in quotes except TRUE and FALSE, 0 and #NAME? problems)
  • Microsoft Support, "VLOOKUP function" (support.microsoft.com/en-us/office/0bbc8083-26fe-4963-8ab8-93a18ad188a1: range_lookup TRUE by default, sorted first column, #N/A, #REF!, #VALUE!, absolute table range, wildcards with FALSE)
  • Microsoft Support, "XLOOKUP function" (support.microsoft.com/en-us/office/b7fd680e-6d10-43e6-84f9-88eae8bf5929: not in Excel 2016 and Excel 2019, exact match by default)
  • Microsoft Support, "How to correct a #VALUE! error" (support.microsoft.com/en-us/office/15e1b616-fbf2-4147-9c0b-0a11a20e409e: + and * may not calculate cells with text, use SUM instead, IFERROR hides all errors)
  • Microsoft Support, "Excel specifications and limits" (15 digits, 64 nested levels, 255 arguments)
  • Google Docs Editors Help, "VLOOKUP" (support.google.com/docs/answer/3093318: is_sorted TRUE by default, FALSE recommended, search down to a larger value, " Apple" and "Apple " differ, wildcards, IFNA, absolute range)
  • Google Docs Editors Help, "XLOOKUP" (support.google.com/docs/answer/12405947)
  • Google Docs Editors Help, "ROUND" (support.google.com/docs/answer/3093440: places optional, 0 by default, rounding by magnitude)
  • Google Docs Editors Help, "IF" (support.google.com/docs/answer/3093364: order of the answers is the most common problem, IFS)
  • Google Docs Editors Help, "AVERAGE" (support.google.com/docs/answer/3093615: text ignored, any number of arguments)
  • Google Docs Editors Help, "COUNTA" (support.google.com/docs/answer/3093991: zero-length strings and spaces count)
  • Google Docs Editors Help, "Keyboard shortcuts for Google Sheets" (support.google.com/docs/answer/181110: F4 and Fn+F4 while entering a formula, F4 as Redo)
  • Pryor Learning and Exceljet (F4 cycle A1, $A$1, A$1, $A1; = comparison not case-sensitive)
  • Ablebits (IF without value_if_false returns FALSE)
  • Spreadsheet Class (Sheets circular dependency shows #REF!)

Checked: 2026-10-19