vlook up help request

mattless1

Board Regular
Joined
Apr 1, 2011
Messages
102
Hi,

I'm trying to complete a vlookup formula, but doesn't seem to be returning the correct info

I have two sheets.
Sheet one cell A1 is where i would like to have the Code returned from sheet two.

I've tried looking for the names, then returns the code against the name in sheet 1. but I'm doing something wrong. i have also tried the Match formula

This is the code I'm using =VLOOKUP(B2,Sheet2!$A$2:$B$4,1,0)

I'd appreciate it if someone could point me in the right direction.

sheet 1
A1 A2 A3
[TABLE="width: 274"]
<tbody>[TR]
[TD]Code[/TD]
[TD]Name[/TD]
[TD]ID [/TD]
[/TR]
[TR]
[TD]#N/A[/TD]
[TD]Paul Mension[/TD]
[TD]206[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]David Docks[/TD]
[TD]210[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Debbie Stock[/TD]
[TD]471[/TD]
[/TR]
</tbody>[/TABLE]

Sheet 2
A1 A2 A3
[TABLE="width: 245"]
<tbody>[TR]
[TD]Code[/TD]
[TD]Name[/TD]
[TD]ID[/TD]
[/TR]
[TR]
[TD]001[/TD]
[TD]Paul Mension[/TD]
[TD]206[/TD]
[/TR]
[TR]
[TD]002[/TD]
[TD]David Docks[/TD]
[TD]210[/TD]
[/TR]
[TR]
[TD]003[/TD]
[TD]Debbie Stock[/TD]
[TD]471[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Vlookup is about using the Left column as reference, now if you duplicated the 001 to 003 to the right of 206 471 and used that you can get the value
 
Upvote 0
Works perfect, thanks so much :) Never though of moving the columns. You learn something new everyday. Appreciate that.
 
Upvote 0
as Gaz says INDEX MATCH is the way to do it, but sometimes its quicker to use what you know, unless you spend time learning a new skill
 
Upvote 0
For Index/Match, try

=Index(Sheet2!$A$2:$A$4,match(B2,Sheet2!$B$2:$B$4,0))

Index the range that you want the result from.
Match is the range to look for the lookup value in.
The ,0 at the end of match says to look for an exact match.

hth

Gaz
 
Upvote 0
I learnt it by understanding that MATCH can be written first to find out what ROW to return, then INDEX would use the row number for the result. You can use different ranges, but you have to accommodate for the offset
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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