Extract specific string of text from cell

CF64

New Member
Joined
Feb 17, 2021
Messages
48
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

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
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,214,912
Messages
6,122,200
Members
449,072
Latest member
DW Draft

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