# Extract data from concatination.

I need a formula to separate out the city names in a concatenated cell. Examples are below.
In column A row 2 & 3.
US-ALABASTER---US-IRVING
US-ATLANTA---US-JACKSONVILLE

The city name will always be after a dash.
I need in column N "ALABASTER", column O "IRVING"
colunmn N "ATLANTA", column O "JACKSONVILLE"

Can anyone help?
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
Simply use the Excel option for "Text To Columns", choose delimited, and see the screenshot below (assuming hyphens are *only* used to delineate each field and not used *within* a field).

Once that is done, you can use additional Excel features on each column to remove any extra spaces, etcetera.
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Older than dirtCommented:
Usage:
In column N
=city1(A2)

In column O
=city2(A2)

``````Function City1(r As Range) As String
Dim strParts() As String

strParts = Split(r, "---")
City1 = Split(strParts(0), "-")(1)
End Function
``````
``````Function City2(r As Range) As String
Dim strParts() As String

strParts = Split(r, "---")
City2 = Split(strParts(1), "-")(1)
End Function
``````
0
For column N, you can use =MID(A2, FIND("-", A2)+1, FIND("---", A2)-FIND("-", A2)-1)
For column O, you can use =RIGHT(A2, LEN(A2)-SEARCH("^^",SUBSTITUTE(A2,"-","^^",LEN(A2)-LEN(SUBSTITUTE(A2,"-","")))))
0
Commented:
Create this function:
``````Public Function Q_29099537(ByVal parmCellText, ByVal parmCityNumber) As String
'parmCityNumber should be 1 or 2
Q_29099537 = Replace(Split(parmCellText, "US-")(parmCityNumber), "-", "")
End Function
``````
In N2, create this formula:
``````=Q_29099537(A2,1)
``````
In O2, create this formula:
``````=Q_29099537(A2,2)
``````
Fill down as necessary
0
Author Commented:
Sorry - thought that I completed that day! Thanks for the support!
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.