Extracting several words from a text string

FKalinx

New Member
Joined
Jul 2, 2014
Messages
39
Hi there,

I am looking at extracting several words from a text string.

In this example:

#interestedin-bus #interestedin-car #interestedin-train #interestedin-bus #interested-in-bike #interested-in-car

I need bus car train bus bike car returned ideally in multiple cells so I can analyse their frequency.

I have tried the =RIGHT(A2,LEN(A2)-SEARCH("-",A2)) but it only picks up the first instance. I then thought I could transpose the text into multiple cells and then run this formula but can't work out how to transpose using blank spaces.

Any help, much appreciated.
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Hi

Excel Formula:
=SUBSTITUTE(SUBSTITUTE(FILTERXML("<y><z>"&SUBSTITUTE(A1," ","</z><z>")&"</z></y>","//z"),"#interested-in-",""),"#interestedin-","")
 
Upvote 0
Works for all versions of Excel.
With original text string in A2
Try in B2:
Code:
=TRIM(MID(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($A2&" ","-in",""),"-","@")," ","@"),"@",REPT(" ",100)),(COLUMNS($A:A)*2-1)*100,100))
drag accross
 
Upvote 0
Hi

Excel Formula:
=SUBSTITUTE(SUBSTITUTE(FILTERXML("<y><z>"&SUBSTITUTE(A1," ","</z><z>")&"</z></y>","//z"),"#interested-in-",""),"#interestedin-","")
Thanks. Which cell do I put the original text? And what do Y and Z mean?

Would this also work in a Google Sheet?
 
Upvote 0
Works for all versions of Excel.
With original text string in A2
Try in B2:
Code:
=TRIM(MID(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($A2&" ","-in",""),"-","@")," ","@"),"@",REPT(" ",100)),(COLUMNS($A:A)*2-1)*100,100))
drag accross
Thanks - unfortunately it hasn't worked - see image. Any ideas? Thanks a million.
 

Attachments

  • Screenshot 2022-08-24 at 09.36.54.png
    Screenshot 2022-08-24 at 09.36.54.png
    115 KB · Views: 10
Upvote 0
just copy/paste into cell B2, why did #REF! appear in formula bar?
In formula bar, try to remove #REF! with $A2
Does it work?
 
Upvote 0
just copy/paste into cell B2, why did #REF! appear in formula bar?
In formula bar, try to remove #REF! with $A2
Does it work?
Thanks, yes it worked partially - see image. Cells F2 and G2 are not extracting correctly.
 

Attachments

  • Screenshot 2022-08-24 at 10.05.35.png
    Screenshot 2022-08-24 at 10.05.35.png
    30.8 KB · Views: 10
Upvote 0
Thanks Bebo021999. Here's the Excel file - cells highlighted in yellow show cells that have not been extracted correctly.

 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,871
Members
449,055
Latest member
excelhelp12345

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