Help & Advice On A VLookup/Match Maybe?

Dazzawm

Well-known Member
Joined
Jan 24, 2011
Messages
3,783
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

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
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
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
[Table="width:, class:head"][tr=bgcolor:#E0E0F0][th] [/th][th]
A
[/th][th]
B
[/th][th]
C
[/th][/tr]
[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
1
[/td][td]Part Number[/td][td]Result[/td][td] formula in B2 copied down[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
2
[/td][td]WA11002R[/td][td]WA11002N[/td][td] =IFERROR(VLOOKUP(LEFT(A2,7)&"*",Sheet2!A:A,1,0),VLOOKUP(LEFT(A2,6)&"*",Sheet2!A:A,1,0))[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
3
[/td][td]WA11005N[/td][td]WA11005R[/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
4
[/td][td]WA11008N[/td][td]WA11008R[/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
5
[/td][td]WA11011N[/td][td]WA11011R[/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
6
[/td][td]WA11012N[/td][td]WA11012R[/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
7
[/td][td]WA11013N[/td][td]WA11013N[/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
8
[/td][td]WA11014N[/td][td]WA11014N[/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
9
[/td][td]WA11016N[/td][td]WA11016R[/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
10
[/td][td]WA11020N[/td][td]WA11020R[/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
11
[/td][td]WA11024N[/td][td]WA11024N[/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
12
[/td][td]WA11025N[/td][td]WA11025R[/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
13
[/td][td]WA11031R[/td][td]WA11031R[/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
14
[/td][td]WA11032N[/td][td]WA11032R[/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
15
[/td][td]WA11041N[/td][td]WA11041N[/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
16
[/td][td]WA11042N-[/td][td]WA11042N[/td][td][/td][/tr]
[/table]
[Table="width:, class:grid"][tr][td]Sheet: Sheet1[/td][/tr][/table]
 
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,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

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