ExcelReady
CourseMock testsFunction guidesBlog
Start freeStart learning for free
ExcelReady

Be Excel-ready before day one. Hands-on practice in your browser, with instant feedback.

Learn

  • Course
  • Mock tests
  • Function guides
  • Blog

Test prep

  • Excel level test
  • Excel test practice
  • Free screening quiz
  • Certificate

Company

  • About
  • Editorial policy
  • Contact
  • Terms
  • Privacy

© 2026 ExcelReady. All rights reserved.

  1. Blog
  2. Logic
  3. How to Combine IF and VLOOKUP in Excel

How to Combine IF and VLOOKUP in Excel

By ExcelReady Team·Updated November 2, 2026·7 min read

The short answer

Put VLOOKUP inside the logical test of IF. For example, =IF(VLOOKUP(E2,A2:D6,3,FALSE)<20,"Reorder","OK") looks up the stock for the code in E2 and returns Reorder when it is below 20. VLOOKUP finds the value, and IF decides what to show. Wrap it in IFERROR or use ISNA when the code might be missing.

Key takeaways

  • The usual pattern is =IF(VLOOKUP(...) test, value_if_true, value_if_false).
  • Always use FALSE as VLOOKUP's last argument so it finds an exact match.
  • To check whether a code exists, test VLOOKUP with ISNA, or use COUNTIF instead.
  • Don't put numbers in quotes in the test: a number compared with "20" is treated as text.
On this page+
  1. How IF and VLOOKUP work together
  2. Example 1: compare a looked-up number with a limit
  3. Example 2: check a looked-up text value
  4. Example 3: check whether a value exists in a list
  5. Example 4: avoid #N/A and blank-cell zeros
  6. Example 5: use IF to choose what VLOOKUP returns
  7. Common mistakes with IF and VLOOKUP
  8. Practise it

To combine IF and VLOOKUP in Excel, put the VLOOKUP inside IF's test: VLOOKUP fetches a value from a table, and IF decides what to show based on it. A typical if vlookup formula is =IF(VLOOKUP(E2,A2:D6,3,FALSE)<20,"Reorder","OK"). This guide walks through the four patterns you'll actually use, on one small stock list, with the result of every formula.

How IF and VLOOKUP work together#

IF asks a yes-or-no question and returns one of two answers. VLOOKUP finds a row by its first column and returns a value from another column. Put them together and the question can be about a value that lives in another table.

Excel formula
=IF(VLOOKUP(lookup_value, table, column, FALSE) test, value_if_true, value_if_false)

Excel works from the inside out. First VLOOKUP returns a value, such as 18. Then IF checks the test, such as 18<20, and returns the matching answer.

All examples use this office-supplies list in A1:D6, with a code typed in E2:

ABCD
1CodeItemStockStatus
2P-101Printer paper45Active
3P-102Toner6Active
4P-103Pens120Active
5P-104Folders18Active
6P-105Staples30Discontinued

If you need a refresher on either function first, read how the IF function works and how VLOOKUP finds a value.

Example 1: compare a looked-up number with a limit#

The most common job is to test a looked-up number. Here we flag items with fewer than 20 in stock:

Excel formula
=IF(VLOOKUP(E2,A2:D6,3,FALSE)<20,"Reorder","OK")
PartWhat it does
VLOOKUP(E2,A2:D6,3,FALSE)Finds the code in E2 and returns column 3, the Stock
<20The test: is the stock below 20?
"Reorder"Shown when the test is TRUE
"OK"Shown when the test is FALSE

With P-104 in E2, VLOOKUP returns 18, so the result is Reorder. With P-101 it returns 45, so the result is OK.

Keep the number 20 out of quotes. VLOOKUP returns a real number, and Excel compares numbers with text in an odd way: any number counts as smaller than any text. So <"20" would be TRUE for every item, even the 120 pens.

To make the limit easy to change, put it in a cell, say G1, and write <G1 instead of <20. When you fill the formula down a list, lock the table and the limit with $: =IF(VLOOKUP(E2,$A$2:$D$6,3,FALSE)<$G$1,"Reorder","OK").

Example 2: check a looked-up text value#

IF can test text too. Put the text in double quotes after an equals sign:

Excel formula
=IF(VLOOKUP(E2,A2:D6,4,FALSE)="Discontinued","Do not order","Can order")

With P-105 in E2, VLOOKUP returns Discontinued, so the result is Do not order. The comparison ignores capital letters, so "discontinued" matches too. It does not ignore spaces: "Discontinued " with a trailing space won't match. The guide to IF with text conditions covers partial matches and other text tests.

Example 3: check whether a value exists in a list#

To test if a code is in the list, check whether VLOOKUP fails. VLOOKUP returns #N/A when it can't find a value, and ISNA turns that into TRUE:

Excel formula
=IF(ISNA(VLOOKUP(E2,A2:A6,1,FALSE)),"Not found","Found")

With P-999 in E2, the result is Not found. With P-102, it's Found. Here the table is just the code column and the column number is 1, because you only care whether the code is there.

A shorter way does the same job without VLOOKUP:

Excel formula
=IF(COUNTIF(A2:A6,E2)>0,"Found","Not found")

COUNTIF counts how many times the code appears. Anything above zero means it exists.

Example 4: avoid #N/A and blank-cell zeros#

When the code might be missing, the whole IF formula shows #N/A, because the error from VLOOKUP passes straight through IF. Wrap the formula in IFERROR to show a message instead:

Excel formula
=IFERROR(IF(VLOOKUP(E2,A2:D6,3,FALSE)<20,"Reorder","OK"),"Code not found")

With P-999 in E2, this returns Code not found. IFERROR hides every error, including typos in your own formula, so test the formula before you wrap it. The article on IFERROR with VLOOKUP compares it with IFNA, which hides only #N/A.

IF also fixes a second annoyance. When the cell VLOOKUP returns is empty, Excel shows 0 instead of a blank. Test for the empty result and return "":

Excel formula
=IF(VLOOKUP(E2,A2:D6,4,FALSE)="","",VLOOKUP(E2,A2:D6,4,FALSE))

See how to make VLOOKUP return a blank instead of 0 for more ways to do this.

Example 5: use IF to choose what VLOOKUP returns#

You can also turn the formula around and put IF inside VLOOKUP. IF then picks the column number. Say F1 holds either Stock or Item:

Excel formula
=VLOOKUP(E2,A2:D6,IF(F1="Stock",3,2),FALSE)

When F1 says Stock, IF returns 3 and VLOOKUP brings back the stock count. Otherwise it returns 2, the item name. The same idea works for two whole lookups, for example a member price list and a standard price list:

Excel formula
=IF(F2="Member",VLOOKUP(E2,H2:I6,2,FALSE),VLOOKUP(E2,K2:L6,2,FALSE))

Only one VLOOKUP runs, depending on F2.

Common mistakes with IF and VLOOKUP#

These cause most wrong results:

  1. Leaving out FALSE. Without it, VLOOKUP does an approximate match and can return a value from the wrong row on an unsorted list. Always end with FALSE.
  2. Numbers in quotes. <"20" compares with text. Write <20.
  3. Numbers stored as text. If the codes are numbers in one table and text in the other, VLOOKUP returns #N/A. Make both the same type.
  4. Brackets in the wrong place. VLOOKUP's closing bracket goes before the comparison: VLOOKUP(...)<20, not VLOOKUP(...<20).
  5. Hard-coded column numbers. If someone inserts a column inside the table, column 3 is no longer Stock. Check the formula after changing the table, or use XLOOKUP (Excel 2021 or Microsoft 365), which points at the column itself.

The IF function guide and the VLOOKUP function guide list every argument if you get stuck.

Practise it#

You learn this pattern by typing it a few times. Practise the IF function in a live spreadsheet: you write each test and the sheet checks it instantly. Then practise VLOOKUP exact match until the four arguments come without thinking, and try the exercise on this page to put the two together.

Try it yourself

This is a live spreadsheet. Type the formula in the green cell and press Enter.

Should we reorder the item whose code is in E2? In F2, look up its Stock (column 3 of A2:D6) and return Reorder if it is below 20, otherwise OK.

fx
ABCDEFG
1
Code
Item
Stock
Status
Code
2
P-101
Printer paper
45
Active
P-104
3
P-102
Toner
6
Active
4
P-103
Pens
120
Active
5
P-104
Folders
18
Active
6
P-105
Staples
30
Discontinued
7
8
9

Tip: Start with =IF(, then write VLOOKUP(E2,A2:D6,3,FALSE)<20 as the test, then the two words in quotes.

Practise this in a lesson

LessonThe IF functionMake a cell show one result or another depending on a condition, like Pass/Fail or Over/Under budget.LessonVLOOKUP exact matchPull product names and prices from a catalog with VLOOKUP, and lock the table so the formula fills down cleanly.Function guideIFLearn Excel's IF function with practical examples: flag budgets, label rows and return blanks. Avoid the classic mistakes and practice live.Function guideVLOOKUPLearn VLOOKUP with clear examples, the 4 most common mistakes, and a live practice exercise you can try in your browser.

Frequently asked questions

Can you use IF and VLOOKUP together in Excel?

+

Yes. The most common way is to put VLOOKUP inside IF's test, such as =IF(VLOOKUP(E2,A2:D6,3,FALSE)<20,"Reorder","OK"). You can also use IF inside VLOOKUP to choose the column or the table.

How do I check if a value exists with IF and VLOOKUP?

+

Use =IF(ISNA(VLOOKUP(E2,A2:A6,1,FALSE)),"Not found","Found"). ISNA is TRUE when VLOOKUP returns #N/A, which means the value is not in the list. =IF(COUNTIF(A2:A6,E2)>0,"Found","Not found") does the same job.

Why does my IF VLOOKUP formula return #N/A?

+

VLOOKUP could not find the lookup value, so the error passes through IF. Check for spaces and typos, make sure the last argument is FALSE, or wrap the formula in IFERROR.

Should I use IF with VLOOKUP or XLOOKUP?

+

Both work the same way inside IF. XLOOKUP needs Excel 2021 or Microsoft 365 and has its own if_not_found argument. VLOOKUP works in every version, which matters if others open your file.

Sources

  • IF function - Microsoft Support
  • VLOOKUP function - Microsoft Support
  • IS functions - Microsoft Support

Written and checked by the ExcelReady Team. First published November 2, 2026. The practice exercise runs in the same formula engine as our lessons. Found a mistake? Read our editorial policy or email hello@excelready.app.

On this page

  1. How IF and VLOOKUP work together
  2. Example 1: compare a looked-up number with a limit
  3. Example 2: check a looked-up text value
  4. Example 3: check whether a value exists in a list
  5. Example 4: avoid #N/A and blank-cell zeros
  6. Example 5: use IF to choose what VLOOKUP returns
  7. Common mistakes with IF and VLOOKUP
  8. Practise it

Keep reading

Logic· 6 min read

IFERROR With VLOOKUP: Replace #N/A With a Message

To replace #N/A from VLOOKUP, wrap it in IFERROR: =IFERROR(VLOOKUP(E2,$A$2:$C$6,3,FALSE),"Not found"). If VLOOKUP finds the value, you see the result; if it returns any error, you see Not found instead. Use IFNA instead of IFERROR when you only want to catch missing values and still see other mistakes.

Logic· 6 min read

The Excel IF Function Explained Simply

The Excel IF function checks a condition and returns one value when it's TRUE and another when it's FALSE. The syntax is =IF(logical_test, value_if_true, value_if_false). For example, =IF(B2>=70,"Pass","Fail") shows Pass for a score of 70 or more and Fail for anything lower. Text results go in double quotes.

Lookups· 6 min read

VLOOKUP in Excel: Step-by-Step for Beginners

VLOOKUP finds a value in the first column of a table and returns a value from the same row in another column. Write =VLOOKUP(what to find, table, column number, FALSE). FALSE means exact match, which is what you want for IDs, codes and names. If nothing matches, VLOOKUP returns #N/A.

More on logic

  • IF With Text in Excel: Check Words and Partial Matches
  • Return Yes or No in Excel With IF
  • IFERROR in Excel: Hide Errors the Right Way
  • IFERROR Return Blank: Hide Errors With an Empty Cell
  • The Excel IFS Function: Cleaner Than Nested IFs
  • ISBLANK, ISNUMBER and ISTEXT in Excel
All logic articles →

Don't just read about Excel. Do it.

Practise real formulas in a live spreadsheet with instant feedback, right in your browser. Nothing to download.

Start learning for free