How to split text

jeffblack

New Member
Joined
Dec 2, 2016
Messages
3
Hello,

I'm looking for a formula that will allow me to split text into 4 rows, text is always in A1 in the format "1/1/1/1" but the numbers could be any length. I've tried righ and left but where the number lengths change it doesn't work for me.
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Welcome to the forums.

First select the cells, then up at the top click the 'Data' tab and the click 'Text to Columns', then make sure 'Delimited' is selected then hit 'Next', then uncheck 'Tab' and check 'Other' and type in / in the box to the right of 'Other', then hit finish.
 
Last edited:
Upvote 0
Code:
Sub split()
Columns("A:D").Insert
   Columns("A:A").TextToColumns Destination:=Range("E1"), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, Other:=True, OtherChar _
        :="/", FieldInfo:=Array(Array(1, 2), Array(2, 2), Array(3, 2), Array(4, 2)), _
        TrailingMinusNumbers:=True
End sub

Try this, it looks for the "/" and splits for that
 
Last edited:
Upvote 0
Thank you for the reply, I was looking for a formula so I wouldn't have to do text to columns every time the data changes.
 
Upvote 0
Then to get them into rows highlight the data then right click and copy the data. → Right click on cell A2 and paste special → Transpose it will move the data from cells A1 B1 C1 and D1 to A2 A3 A4 A5
 
Upvote 0
Code:
Columns("A:A").TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, Other:=True, OtherChar _
        :="/", FieldInfo:=Array(Array(2, 1), Array(2, 2), Array(2, 3), Array(2, 4)), _
        TrailingMinusNumbers:=True
        Range("A2") = Range("B1")
        Range("A3") = Range("C1")
        Range("A4") = Range("D1")
        Range("B1:D1").Delete
Watch out as this meddles with the cells around and thus only works on nearly empty worksheets, unless you dont mind data going missing.
Tell me if this helped you out
 
Last edited:
Upvote 0
If you are looking for a formula, how about something like this:


Excel 2010
ABCDE
1StringFirstSecondThirdFourth
21/2/3/41234
Sheet1
Cell Formulas
RangeFormula
B2=LEFT(A2,FIND("/",A2)-1)
C2=TRIM(MID(SUBSTITUTE(A2,"/",REPT(" ",100)),100,100))
D2=TRIM(MID(SUBSTITUTE(A2,"/",REPT(" ",100)),200,100))
E2=TRIM(MID(SUBSTITUTE(A2,"/",REPT(" ",100)),300,100))


Source: Extracting a Substring Between Second and Third Delimiters [SOLVED]
 
Upvote 0
You can do it with one formula
Enter in B1 and copy across

=TRIM(MID(SUBSTITUTE("/"&$A1,"/",REPT(" ",99)),99*COLUMNS($A:A),99))


Excel 2016 (Windows) 32 bit
ABCDE
11/2/3/41234
Sheet1
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,869
Members
449,054
Latest member
juliecooper255

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