Text to columns excel formula

Celticshadow

Active Member
Joined
Aug 16, 2010
Messages
414
Office Version
  1. 365
Platform
  1. Windows
Hi Forum

May I ask members if they would be kind enough to supply a formula to split the below info into separate columns by way of formula. An explanation of the info is as follows
2-10 - DARK MYSTERY - 5/1 > 3/1 > 2/1 > 1/1
first numbers is a time 2-10
Then a horses name Dark Mystery
Then a set of betting odds 5/1 > 3/1 > 2/1 > 1/1 (this line of odds can be just one set
ie 5/1
upto 7 sets
ie 5/1 > 3/1 > 2/1 > 1/1 > 8/13 > 1/2 > 4/11

I would also add that the info would start in cell A1 and can run down into cell A150 so I would need to able to copy down the formula per line.

So I would like it set out that if the info is in Col A1 then it would follow that in

Col B1 = time
Col C1 = Horse Name
Col D1 = Odds

May I also ask if it would be possible to change the time layout to a decimal thus instead of 2-10 it would read 2.10

Many thanks in advance for any help provided as it will be much appreciated and I will be sure to provide feedback as is neccessary. Thanks again.

Regards

PS Image attached also for interest.
 

Attachments

  • Mr Excel Odds Line.png
    Mr Excel Odds Line.png
    15.2 KB · Views: 8
  • Mr Excel Odds Line 2.png
    Mr Excel Odds Line 2.png
    17.4 KB · Views: 7

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
How about
Fluff.xlsm
ABCDE
12-10 - DARK MYSTERY - 5/1 > 3/1 > 2/1 > 1/12.10 DARK MYSTERY 5/1 > 3/1 > 2/1 > 1/1
Data
Cell Formulas
RangeFormula
B1:D1B1=SUBSTITUTE(TEXTSPLIT(A1," -"),"-",".")
Dynamic array formulas.
 
Upvote 0
Solution
How about
Fluff.xlsm
ABCDE
12-10 - DARK MYSTERY - 5/1 > 3/1 > 2/1 > 1/12.10 DARK MYSTERY 5/1 > 3/1 > 2/1 > 1/1
Data
Cell Formulas
RangeFormula
B1:D1B1=SUBSTITUTE(TEXTSPLIT(A1," -"),"-",".")
Dynamic array formulas.
Hi Fluff

Many thanks for replying it is much appreciated. I am delighted to say that your solution works an absolute treat and once again I amazed at the knowledge that is so freely shared by yourself and other forum members. Many many thanks for your considered help.

Regards
 
Upvote 0
Glad to help & thanks for the feedback.
 
Upvote 0
Using my approach you'll need a custom function in VBA. Hopefully you know how to do that.

VBA Code:
Function ExtractName(psText)

    Dim iChar As Long
    
    Dim sName As String
    
    Dim sChar As String
    
    Dim bIsAlpha As Boolean
    
    For iChar = 1 To Len(psText)
        
        sChar = Mid(psText, iChar, 1)
        
        bIsAlpha = Not IsNumeric(sChar) _
               And Not sChar = "-" _
               And Not sChar = ">" _
               And Not sChar = "/"
               
        If bIsAlpha Then sName = sName & sChar
               
    Next iChar
    
    ExtractName = Trim(sName)
    
End Function

Odds.xlsm
ABCD
1TimeNameOdds
22-10 - DARK MYSTERY - 5/1 > 3/1 > 2/1 > 1/12:10 DARK MYSTERY- 5/1 > 3/1 > 2/1 > 1/1
Sheet1
Cell Formulas
RangeFormula
B2B2=SUBSTITUTE(LEFT(A2,FIND("~",SUBSTITUTE(A2,"-","~",2))-1),"-",":")
C2C2=ExtractName(A2)
D2D2=TRIM(MID(A2, (SEARCH(C2,A2,1)+LEN(C2)), LEN(A2)- (SEARCH(C2,A2,1)+LEN(C2) -1) ) )
 
Upvote 0
I misread your post. The odds should not include the leading dash.

Odds.xlsm
ABCD
1TimeNameOdds
22-10 - DARK MYSTERY - 5/1 > 3/1 > 2/1 > 1/12:10 DARK MYSTERY 5/1 > 3/1 > 2/1 > 1/1
Sheet1
Cell Formulas
RangeFormula
B2B2=SUBSTITUTE(LEFT(A2,FIND("~",SUBSTITUTE(A2,"-","~",2))-1),"-",":")
C2C2=ExtractName(A2)
D2D2=MID(A2, (SEARCH(C2,A2,1)+LEN(C2)+2), LEN(A2)- (SEARCH(C2,A2,1)+LEN(C2) -1) )
 
Upvote 0

Forum statistics

Threads
1,215,465
Messages
6,124,982
Members
449,201
Latest member
Lunzwe73

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