# formula to add space between alpha numeric string

hello

i need help with the formula.

i have mixed alpha numberic string in many cells in column A and i want a formula in column B that adds space between alpha and numbers  either way. for example if   an text with number is attached like this  James54125 Nick5411 then in ciolumn B result James 54125 Nick 5411 or  the other way  5412211James 74555555Nicolay  result in column B  5412211 James 74555555 Nicolay

please see attached file.  i found the formula =TRIM(LEFT(A2, MATCH(TRUE, MID(A2, {1,2,3,4,5,6,7}, 1)>"9", 0) - 1) & " " & MID(A2, MATCH(TRUE, MID(A2, {1,2,3,4,5,6,7}, 1)>"9", 0), 100) )

but it does not work, please see attached file.
Book2.xlsx
LVL 6
###### Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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:
I think that is too complicated to make as a formula, with text and numbers mixed several times.
Try this UDF function (VBA), see sheet.

``````Function SpaceTextAndNumbers(Txt As String) As String
Dim i As Integer, TextType As String
If Asc(Mid(Txt, 1, 1)) >= 48 And Asc(Mid(Txt, 1, 1)) <= 57 Or Asc(Mid(Txt, 1, 1)) = 46 Then
TextType = "Nbr"
Else
TextType = "Txt"
End If
i = 2
Do
If Mid(Txt, i, 1) <> " " Then
If Asc(Mid(Txt, i, 1)) >= 48 And Asc(Mid(Txt, i, 1)) <= 57 Or Asc(Mid(Txt, i, 1)) = 46 Then
If TextType = "Txt" Then
TextType = "Nbr"
Txt = Left(Txt, i - 1) & " " & Right(Txt, Len(Txt) - i + 1)
End If
Else
If TextType = "Nbr" Then
TextType = "Txt"
Txt = Left(Txt, i - 1) & " " & Right(Txt, Len(Txt) - i + 1)
End If
End If
End If
i = i + 1
Loop Until i > Len(Txt)
SpaceTextAndNumbers = Application.WorksheetFunction.Trim(Txt)
End Function
``````
Space-text-and-numbers.xlsm
0

Experts Exchange Solution brought to you by

Your issues matter to us.

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

Author Commented:
Ejgil,

you are brilliant
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.