VLOOKUP Errors Driving Me Insane :-)

Alex Caldecott

New Member
Joined
Nov 15, 2023
Messages
13
Office Version
  1. 365
Platform
  1. Windows
HELP!

I'm trying to pull through some prices from one sheet into another using VLOOKUP. It's working for most but some are throwing an error #N/A.

Formula I'm using - =VLOOKUP(B2,Sheet1!A2:C8039,2,FALSE)

A few screenshots attached.

Some of the errors are being thrown because the items are not in the second sheet but most of them are there and just not pulling through.

What am I missing?
 

Attachments

  • Screenshot 2025-01-14 164021.png
    Screenshot 2025-01-14 164021.png
    128.8 KB · Views: 7
  • Screenshot 2025-01-14 164218.png
    Screenshot 2025-01-14 164218.png
    126.4 KB · Views: 7
  • Screenshot 2025-01-14 164241.png
    Screenshot 2025-01-14 164241.png
    124.1 KB · Views: 6
  • Screenshot 2025-01-14 164317.png
    Screenshot 2025-01-14 164317.png
    103.3 KB · Views: 7

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
You need to lock the row references on your look up range, or else as you copy the formula down, the rows of that range will shift accordingly.
So enter this formula and copy it down:
Excel Formula:
=VLOOKUP(B2,Sheet1!A$2:C$8039,2,FALSE)

Note the #N/A errors occur when it does not find a match.
You can use the IFERROR formula to address that, if you like, i.e.
Excel Formula:
=IFERROR(VLOOKUP(B2,Sheet1!A$2:C$8039,2,FALSE),"No Match")
 
Upvote 0
Solution
You are welcome.
Glad I was able to help!
 
Upvote 0
A few other things to consider.
  • Firstly, I suggest that you investigate XL2BB for providing sample data to make it easier for helpers by not having to manually type out sample data to test with. We cannot copy from pictures to test. :)
    (If you have trouble with XL2BB, review the "XL2BB Icons greyed out" link in the 'Known XL2BB issues' section near the top of the XL2BB Instructions page linked above.)

  • Since this formula is only looking up in columns A:B of Sheet1, you are best to only have those two columns as the lookup range in your lookup formula. The reason is that if A:C is referenced like you have and a value in column C of Sheet1 is changed, that will cause all the lookup formulas to recalculate even though there is no possibility of that recalculation producing any different results from the formulas. It may not be crucially important if your worksheet is not too big, but it makes sense to me to be efficient in that regard.

  • Since the VLOOKUP returns a #N/A error if the lookup value is not found, it also makes sense to me to just target that error with the formula. That way you wouldn't accidentally hide some other sort of error if it occurred. So I would suggest IFNA() rather than IFERROR()

  • It looks like you data might be quite big and since you have Excel 365, instead of copying the formula down hundreds of rows, you can get all the hundreds (I'm guessing the number) of results from a single formula in the top cell.

  • Finally, again since you have 365, XLOOKUP could be considered as you do not have to trap an "error" at all because that function has an optional argument for what to return if the lookup value is not found.
So to demonstrate my points, in the second sheet below
I have the two formulas from post 2 in columns H:I
The cell J2 formula is reducing the lookup range to the two relevant columns in Sheet1 but it also does not need to be copied down.
Cell K2 is similar but showing that IFNA can be used
The L2 formula also does not need to be copied down and shows how XLOOKUP can provide the same results without any "error" type function.

Alex Caldecott.xlsm
AB
1Product CodePrice
2Prod Code 28644.88
3Prod Code 79841.49
4Prod Code 75264.48
5Prod Code 18633.59
6Prod Code 8790.62
7Prod Code 49127.2
8Prod Code 99562.2
9Prod Code 74696.83
10Prod Code 33159.77
11Prod Code 99346.52
12Prod Code 52280.3
13
Sheet1


Alex Caldecott.xlsm
BHIJKL
1Product Code
2Prod Code 79841.4941.4941.4941.4941.49
3Prod Code 18633.5933.5933.5933.5933.59
4Prod Code 202#N/ANo Match#N/ANo MatchNo Match
5Prod Code 74696.8396.8396.8396.8396.83
6Prod Code 817#N/ANo Match#N/ANo MatchNo Match
7Prod Code 811#N/ANo Match#N/ANo MatchNo Match
8Prod Code 99346.5246.5246.5246.5246.52
9Prod Code 49127.227.227.227.227.2
10Prod Code 28644.8844.8844.8844.8844.88
Worksheet
Cell Formulas
RangeFormula
H2:H10H2=VLOOKUP(B2,Sheet1!A$2:C$8039,2,FALSE)
I2:I10I2=IFERROR(VLOOKUP(B2,Sheet1!A$2:C$8039,2,FALSE),"No Match")
J2:J10J2=VLOOKUP(B2:B10,Sheet1!A$2:B$8039,2,0)
K2:K10K2=IFNA(VLOOKUP(B2:B10,Sheet1!A$2:B$8039,2,0),"No Match")
L2:L10L2=XLOOKUP(B2:B10,Sheet1!A2:A8039,Sheet1!B2:B8039,"No Match")
Dynamic array formulas.
 
Upvote 0

Forum statistics

Threads
1,225,739
Messages
6,186,738
Members
453,369
Latest member
juliewar

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