Multiple Search and Return Formula

LearningExcel101

New Member
Joined
Dec 3, 2024
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I have been struggling with this one for a couple days now. I need to match the first 21 characters in a cell to a list on a separate tab, and if there is a match, return the value in a different column from the same row back to the original tab. Cant get a VLOOKUP to work, please help.

Thank you

Example Book:
(cant download xl2bb on work computer)

Compare 'Sheet 2' cell 'A2' first 21 characters in the cell to find a matching first 21 characters on 'Sheet1' B2:B14 range and then return Sheet 1's 'A2' value to Sheet 2's "B2".

Sheet 2:
Sheet 2.png



Sheet 1:
sheet 1.png
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
VLOOKUP wouldn't do it as it requires search-in column to be leftmost, and return-from column to be rigth from it. As you are using Microsoft 365 you can use XLOOKUP instead:

VBA Code:
=XLOOKUP(LEFT(A2,23),LEFT(Sheet1!$B$2:$B$20,23),Sheet1!$A$2:$A$20)

In old Excel versions nested INDEX and MATCH functions could be used. Probably this:
Excel Formula:
=INDEX(Sheet1!$A$2:$A$20,MATCH(LEFT(A2,23),LEFT(Sheet1!$B$2:$B$20,23),0))

or
Excel Formula:
=INDEX(Sheet1!$A$2:$A$20,MATCH(LEFT(A2,23)&"*",Sheet1!$B$2:$B$20,0))
shall do the job
 
Upvote 0
Solution
Another XLOOKUP possibility
Excel Formula:
=XLOOKUP(LEFT(A2,21)&"*",Sheet1!B$2:B$20,Sheet1!A$2:A$20,,2)

Or if you want to use VLOOKUP
Excel Formula:
=VLOOKUP(LEFT(A2,21)&"*",CHOOSECOLS(Sheet1!A:B,2,1),2,0)
 
Upvote 0
PS. of course in formulas proposed above use LEFT(... , 21) somehow I changed it to 23 :-D
 
Upvote 0
You're welcome. Glad we could help. Thanks for the follow-up.
 
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,254
Members
452,900
Latest member
LisaGo

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