VLOOKUP problem

busdriver12

New Member
Joined
Apr 17, 2011
Messages
20
Office Version
  1. 365
I have to admit that in all the years I have been using Excel I have never had to use this function. However, I've looked at various examples over the years and had a loose understanding of it.

I have been presented with a problem at work for which I cannot find why it throws up a #N/A error. I'll keep it simple:

In a workbook I have a sign on sheet (called SignOn) consisting of 4 columns (Shift number, Driver name, Unique Staff ID and column for their signature).

ShiftDriverStaff IDSignature
4200J Bloggs?
4201J Smith?

<tbody>
</tbody>

In a second sheet (called NAMES) - it is a simple table consisting of the drivers ID number in column A and their name in column B.

Staff IDName
2001J Blogs
2052J Smith

<tbody>
</tbody>


In the sign on sheet I want to type in the driver's name (Col B) and use VLOOKUP to insert the driver's Staff number from the NAMES sheet into Col C. I named a range (Data) in the NAMES sheet containing the table used in the VLOOKUP formula. formula:

Code:
=VLOOKUP(B2,Data,1,FALSE)

This throws up a #N/A error. The result I am expecting is the Staff ID for each name ("2001" and "2052" respectively) to be inserted into C2 and C3 of the SignOn sheet. I've used the Error Checking and Evaluate Formula in the Formula tab on the ribbon to try to pin down and it tells me that there data being looked up is not available (hence #N/A) to the formula, but as far as I can see it is there.

I can't help but feeling that there is a piece of logic or a crucial step I am missing.

Thanks in advance
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
maybe try:
Code:
=INDEX($G$2:$G$3,MATCH(B2,$H$2:$H$3,0))
adjust ranges suitably

A
B
C
D
E
F
G
H
1
ShiftDriverStaff IDSignatureStaff IDName
2
4200​
J Bloggs
#N/A​
2001​
J Blogs
3
4201​
J Smith
2052​
2052​
J Smith
 
Last edited:
Upvote 0
Vlookup only works if the thing you are searching for is in the first column of the lookup data. This is a good situation to use Index+Match. I turned the lookup data into a table and used the following formula.

Code:
=INDEX(Table6[Staff ID],MATCH(B2,Table6[Name],0))

You can always just put hard coded ranges in there like this.

Code:
=INDEX($J$1:$J:100,MATCH(B2,$I$1:$I$100,0))
, where column J is what you want to return and column I is what you are looking up.
 
Upvote 0
Thanks for the info lrobbo314. I found the answer to my problem where you stated:

Vlookup only works if the thing you are searching for is in the first column of the lookup data. This is a good situation to use Index+Match. I turned the lookup data into a table and used the following formula.

The first sentence gave me a clue and what I did was to swap the columns in the lookup table on the NAMES sheet containing the lookup data. After doing this and using the formula in Col C of the SignOn sheet:

Code:
=VLOOKUP(B4,Names,2,FALSE)

produced the result I was expecting. I am also going to use the Index/Match suggestion as well as a learning exercise so I can better understand the mechanism of doing these sorts of lookups.

Many thanks!
 
Upvote 0
Thanks for the reply sandy666.

I am going to implement your suggestion into my problem to help me understand an alternate approach to my problem.

maybe try:
Code:
=INDEX($G$2:$G$3,MATCH(B2,$H$2:$H$3,0))
adjust ranges suitably

Many thanks!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,804
Messages
6,121,652
Members
449,045
Latest member
Marcus05

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