How to return only part of a string from a list?

FlashDota

New Member
Joined
Jun 11, 2023
Messages
33
Office Version
  1. 2021
Platform
  1. Windows
Let's say I have in sheet 1 cell A1: The best scenes from Jursassic Park

In sheet 2 I have a list like in the picture:
A1: Jursassic Park
A2: The Bourne Identity

I want a formula where if a part of the value in A1 is found in that list, return only that title. See pictures for example
 

Attachments

  • Screenshot 2023-08-31 103324.png
    Screenshot 2023-08-31 103324.png
    14.3 KB · Views: 15
  • Screenshot 2023-08-31 103339.png
    Screenshot 2023-08-31 103339.png
    10.3 KB · Views: 15

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
I don't know if it is possible with your data but I included an example in case more than 1 item from Sheet2 is found.

FlashDota.xlsm
A
1
2Jurassic Park
3The Bourne Identity
4Best Scenes
5
Sheet2


FlashDota.xlsm
AB
1
2The best scenes from Jurassic ParkJurassic Park, Best Scenes
Sheet1
Cell Formulas
RangeFormula
B2B2=LET(r,Sheet2!A$2:A$100,TEXTJOIN(", ",1,FILTER(r,ISNUMBER(SEARCH(r,A2))*(r<>""))))


BTW, I suggest that you investigate XL2BB for providing sample data to make it easier for helpers by not having to manually type out sample data to test with.
 
Upvote 0
Solution
The answer from Petter_SSs is excelent. But I would like add a few points.
Use tabels for both your lists, so it is easier to expand.

Second is add an IFERROR function, in case there NO matches.

My example without the LET-function, but with table ref instead.
Excel Formula:
=IFERROR(TEXTJOIN(", ",TRUE,FILTER(MyList[List],ISNUMBER(SEARCH(MyList[List];A2))*(MyList[List]<>""))),"Not in list")



1693482461777.png
1693482485617.png
 
Upvote 0
There is no reason to use Iferror, which will hid any error, just use the Ifempty argument of filter
Excel Formula:
=LET(r,Sheet2!A$2:A$100,TEXTJOIN(", ",1,FILTER(r,ISNUMBER(SEARCH(r,A2))*(r<>""),"Not in list")))
 
Upvote 0
I don't know if it is possible with your data but I included an example in case more than 1 item from Sheet2 is found.

FlashDota.xlsm
A
1
2Jurassic Park
3The Bourne Identity
4Best Scenes
5
Sheet2


FlashDota.xlsm
AB
1
2The best scenes from Jurassic ParkJurassic Park, Best Scenes
Sheet1
Cell Formulas
RangeFormula
B2B2=LET(r,Sheet2!A$2:A$100,TEXTJOIN(", ",1,FILTER(r,ISNUMBER(SEARCH(r,A2))*(r<>""))))


BTW, I suggest that you investigate XL2BB for providing sample data to make it easier for helpers by not having to manually type out sample data to test with.
Thank you very much, I think this is the solution
 
Upvote 0
You're welcome. Thanks for the follow-up. Might be set to include the "Not in list" per @Fluff's modification or return just "" as below if no matches are found.
Excel Formula:
=LET(r,Sheet2!A$2:A$100,TEXTJOIN(", ",1,FILTER(r,ISNUMBER(SEARCH(r,A2))*(r<>""),"")))
 
Upvote 0

Forum statistics

Threads
1,223,880
Messages
6,175,154
Members
452,615
Latest member
bogeys2birdies

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