Extract specific string of text from cell

CF64

Board Regular
Joined
Feb 17, 2021
Messages
50
Office Version
  1. 365
Platform
  1. Windows
Hello,
I have a column of cells which contains strings of text separated by line breaks.
Is there a formula which I could use to find a string which starts with specific text and pull that string into the adjacent cell?
For example, in the table below "Massachusetts:..." appears in multiple cells with a different city after the ":"
Is there a formula to enter in the adjacent cell in Column B which searches for "Massachusetts:" and returns the entire string (i.e. Massachusetts: City) regardless of which line it appears on in each cell in Column A?
Thank you for your consideration of my question

Column AColumn B
Massachusetts: Boston
Connecticut: Hartford
California: Los Angeles
Massachusetts: Boston
Connecticut: New Haven
California: San Diego
Massachusetts: Boston
Massachusetts: Boston
Connecticut: Hartford
California: Sacramento
Massachusetts: Salem
Massachusetts: Salem
 
@gyagos please do not hijack another members thread. You need to start a thread of your own. Thanks
 
Upvote 0

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Thought I'd posted that, but how about
Excel Formula:
=TEXTJOIN(CHAR(10),,FILTERXML("<k><m>"&SUBSTITUTE(SUBSTITUTE(A2,CHAR(10),"</m><m>"),":","</m><m>")&"</m></k>","//m[starts-with(.,'Mass')]/following::m[1]"))
Thank you!
 
Upvote 0

Forum statistics

Threads
1,226,729
Messages
6,192,695
Members
453,747
Latest member
tylerhyatt04

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