Parsing text with different number of dashes

Avit

Board Regular
Joined
Jan 9, 2013
Messages
85
Platform
  1. MacOS
I have a list of name conventions
Some have three dashes, e.g. AA-BB-CCC
Some have 4, e.g. AAA-BB-CCC-DD.

Assume also the length of each word can be anywhere from 2 to 4 letters.
e.g.
AAA-BB-CC
or
AA-BBB-CCC
etc.


I want to move separate them all into columns (3 to 4, as needed). or in other words, I need to find a way for Excel to extract all text between 2 dashes, for the first appearance, the second, the third and when applicable the forth.

How do I do that?

Thanks a lot!!
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Thanks all, found a solution (yes, with AI, not sure if I am allowed to post it, so I am not, but it's working). Thanks!!
 
Upvote 0
Thanks all, found a solution (yes, with AI, not sure if I am allowed to post it, so I am not, but it's working). Thanks!!
My understanding is that it is perfectly ok for you to post what worked for you and mark is as the solution, so that it may help others with a similar issue.
Just don't do a straight cut and paste of the whole spiel that the AI normally comes out with.
 
Upvote 0
Oh, in that case:
Column 1:
=LEFT(A1, FIND("-", A1) - 1)

Column 2:
=MID(A1, FIND("-", A1) + 1, FIND("-", A1, FIND("-", A1) + 1) - FIND("-", A1) - 1)

Column 3:
=IFERROR(MID(A1, FIND("-", A1, FIND("-", A1) + 1) + 1, IFERROR(FIND("-", A1, FIND("-", A1, FIND("-", A1) + 1) + 1) - FIND("-", A1, FIND("-", A1) + 1) - 1, LEN(A1))), "")

Column 4:
=IFERROR(MID(A1, FIND("-", A1, FIND("-", A1, FIND("-", A1) + 1) + 1) + 1, LEN(A1) - FIND("-", A1, FIND("-", A1, FIND("-", A1) + 1) + 1)), "")
 
Upvote 0
Additionally, you could use Power Query to split the data to multiple cells.
 
Upvote 0

Forum statistics

Threads
1,223,889
Messages
6,175,224
Members
452,620
Latest member
dsubash

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