Home โ€บ Office work โ€บ VLOOKUP Formula: Ask AI to Merge Two Excel Tables

VLOOKUP Formula: Ask AI to Merge Two Excel Tables

When this happens

Your order sheet has product codes and quantities, but the prices live on a separate sheet called 'Prices'. Looking up each price by hand would take forever. Describe both tables and where you want the result, and the AI will give you a formula that connects them.

Watch the video

Ask like this

Excel: Sheet1 has product codes in A and quantities in B. The 'Prices' sheet has codes in A and prices in B. Give me one formula for column C that pulls the matching price, and how to fill it down.

The answer we got

Example AI chat
YouExcel: Sheet1 has product codes in A and quantities in B. The 'Prices' sheet has codes in A and prices in B. Give me one formula for column C that pulls the matching price, and how to fill it down.
AIPut this formula in cell C2 on Sheet1:=VLOOKUP(A2,Prices!A:B,2,FALSE)It looks for the code in A2 in column A of the 'Prices' sheet and returns the price from the 2nd column (B) of that row. FALSE means it only accepts an exact match. Select C2 and double-click the small square at its bottom-right corner (the fill handle) to copy the formula down. If a code isn't on the Prices sheet, you'll see #N/A, so check that code for typos or extra spaces.
Example: Sheet1 with prices pulled from the 'Prices' sheet (P-101 $15, P-102 $20, P-103 $30)
1A CodeB QtyC Price (VLOOKUP)
2P-1023$20
3P-1015$15
4P-1032$30
5P-1021$20

โœ… Put the formula in C2 and fill it down to get each price. Add =B2*C2 in column D for the line totals, and the 4 orders come to $215.

Tips for better results

  1. On a newer Excel? Try XLOOKUP

    Microsoft 365 and Excel 2021 or later have XLOOKUP. You pick the lookup column and the return column separately, and you can set what to show when nothing matches.

    =XLOOKUP(A2,Prices!A:A,Prices!B:B,"Not found")
  2. Show a blank instead of #N/A

    If some codes aren't on the price list yet, wrap the formula in IFERROR to show a blank instead of #N/A. Just make sure you still check for the missing codes.

    =IFERROR(VLOOKUP(A2,Prices!A:B,2,FALSE),"")
  3. Keep going with line totals

    Once the prices are in, multiply quantity by price in the next column. You can also just ask the AI to "add a total column too."

    =B2*C2

Today's checklist

FAQ

The code is definitely there, but I get #N/A.

Usually there's a trailing space, or one side is stored as a number and the other as text. Compare the two cells with a formula like =A2=Prices!A2, or ask the AI: "I get #N/A. Walk me through the likely causes in order."

Is the formula the same in Google Sheets?

Yes. VLOOKUP works the same way in Google Sheets. If the sheet name has a space, wrap it in single quotes, like 'Price list'!A:B.

What if the column I search is to the right of the price?

VLOOKUP needs the lookup column to be the leftmost column of the range. If you can't reorder the columns, use XLOOKUP or INDEX and MATCH. Describe your layout and ask the AI for that version.

More in this category

๐Ÿ’ผ Office workMake a Table in Excel: Just Paste It and Ask AITurn messy text into a clean Excel table๐Ÿ’ผ Office workExcel Sum Only 'Done' Rows: Ask AI for the SUMIF FormulaTotal the amounts only for rows marked Done๐Ÿ’ผ Office workExcel Pivot Table: Ask AI in One LineSee sales totals by region at a glance

โ€น All Office work guides

AI answers can vary by service and version. Double-check anything important before you use it.

Works in ChatGPT, Claude or Gemini.