Help & Advice On A VLookup/Match Maybe?

Dazzawm

Well-known Member
Joined
Jan 24, 2011
Messages
3,748
Office Version
  1. 365
Platform
  1. Windows
I don't really know how to explain this!! I have 2 sheets with a massive amount of data. Sheet 1 will have numbers with a 2 letter prefix then 4 or 5 numbers then letters again, and so will sheet 2. I need to match up ignoring the last letters.


Excel 2010
A
1PartNo
2WA11002R
3WA11005N
4WA11008N
5WA11011N
6WA11012N
7WA11013N
8WA11014N
9WA11016N
10WA11020N
11WA11024N
12WA11025N
13WA11031R
14WA11032N
15WA11041N
16WA11042N-OS
Sheet1




Excel 2010
A
1PartNo
2WA11002N
3WA11005R
4WA11008R
5WA11011R
6WA11012R
7WA11013N
8WA11014N
9WA11016R
10WA11020R
11WA11024N
12WA11025R
13WA11031R
14WA11032R
15WA11041N
16WA11042N
Sheet2



As you can see some end with R and some end with N but I need the formula or code to match up the prefix and numbers so the result would look like below. Obviously using just VLookup it would return a lot of N/A because they need to be an exact match. I hope someone can make some sense of this!!

Intended Result


Excel 2010
AB
1PartNoPartNo
2WA11002RWA11002N
3WA11005NWA11005R
4WA11008NWA11008R
5WA11011NWA11011R
6WA11012NWA11012R
7WA11013NWA11013N
8WA11014NWA11014N
9WA11016NWA11016R
10WA11020NWA11020R
11WA11024NWA11024N
12WA11025NWA11025R
13WA11031RWA11031R
14WA11032NWA11032R
15WA11041NWA11041N
16WA11042N-OSWA11042N
Sheet1
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
You can use VLOOKUP with a wildcard:
Code:
=VLOOKUP(LEFT(A2,LEN(A2)-1)&"*",Sheet2!$A$2:$A$100,1,FALSE)
 
Upvote 0
Thanks but that's not working for me, just returning #N/A all the way down.
 
Upvote 0
Can you post a link to a sample Excel file please? Without any sensitive data of course...
 
Upvote 0
Your sample data shows just a single letter as the suffix, but your explanation implies there could be more than 1 letter as a suffix.

Try this in sheet2 Cell B2 copied down. NOTE: it is an array formula so must be confirmed with ctrl+shift+enter, not just enter

=VLOOKUP(LEFT(A2,MATCH(TRUE,ISERROR(VALUE(MID(A2,ROW(INDIRECT("3:"&LEN(A2))),1))),0)+1)&"*",Sheet1!$A$2:$A$2000,1,FALSE)
 
Last edited:
Upvote 0
If always
2-letter suffix
followed by either 4 OR 5 Numbers

then try this

=IFERROR(VLOOKUP(LEFT(A2,7)&"*",Sheet2!A:A,1,0),VLOOKUP(LEFT(A2,6)&"*",Sheet2!A:A,1,0))

Excel 2016 (Windows) 32 bit
A
B
C
1
Part NumberResult formula in B2 copied down
2
WA11002RWA11002N =IFERROR(VLOOKUP(LEFT(A2,7)&"*",Sheet2!A:A,1,0),VLOOKUP(LEFT(A2,6)&"*",Sheet2!A:A,1,0))
3
WA11005NWA11005R
4
WA11008NWA11008R
5
WA11011NWA11011R
6
WA11012NWA11012R
7
WA11013NWA11013N
8
WA11014NWA11014N
9
WA11016NWA11016R
10
WA11020NWA11020R
11
WA11024NWA11024N
12
WA11025NWA11025R
13
WA11031RWA11031R
14
WA11032NWA11032R
15
WA11041NWA11041N
16
WA11042N-WA11042N
Sheet: Sheet1
 
Upvote 0
Your sample data shows just a single letter as the suffix, but your explanation implies there could be more than 1 letter as a suffix.

Try this in sheet2 Cell B2 copied down. NOTE: it is an array formula so must be confirmed with ctrl+shift+enter, not just enter

=VLOOKUP(LEFT(A2,MATCH(TRUE,ISERROR(VALUE(MID(A2,ROW(INDIRECT("3:"&LEN(A2))),1))),0)+1)&"*",Sheet1!$A$2:$A$2000,1,FALSE)

Seems to work great, thanks for your help. Also jkpieterse.
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,588
Members
449,039
Latest member
Arbind kumar

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