Help With Splitting Text String With Formulas

denzo36

Board Regular
Joined
Sep 22, 2019
Messages
218
Office Version
  1. 365
Platform
  1. Windows
Hi guys,

I have a text string coming in from a SQL server query to Excel that is made up of 4 parts always separated by a ':' ';' and ',' each time.
I need to try and extract each part of the text string into the 4 bits and can't seem to get the formulas correct. Unfortunately I can't go the VBA or Power Query route, it has to be excel formulas.

The left and right bits are easy to get via the LEFT and RIGHT functions - how would I get the middle two bits?

Examples of the text string are:

John Murphy:Full License;01,33
Mary Burke:Provisional License;0,45
David Bing:Full License;04,87
Sarah James:Provisional License;05,50

As you notice,first part of the string is the start of the string to the ':' second part of the string is what's in between the ':' and the ';' third part of the string is what's in between the ';' and the ',' and final part of the string is from the ',' to the end of the string

Any ideas?
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
This will get the string between : and ;

=MID(A11, FIND(":",A11)+1, FIND(";",A11)-FIND(":",A11)-1)

similarly for ; and ,
 
Upvote 0
Here is an alternative solution using Get & Transform which is on the Data Tab of the Ribbon. Mcode follows.

Rich (BB code):
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Split Column by Delimiter" = Table.SplitColumn(Source, "Column1", Splitter.SplitTextByAnyDelimiter({":",";",","}, QuoteStyle.Csv), {"Column1.1", "Column1.2", "Column1.3", "Column1.4"})
in
    #"Split Column by Delimiter"

Book12
ABCD
1Column1.1Column1.2Column1.3Column1.4
2John MurphyFull License0133
3Mary BurkeProvisional License045
4David BingFull License0487
5Sarah JamesProvisional License0550
Sheet2
 
Upvote 0
Any ideas?
You could also use Text to Columns -> Delimited with ...

1592446937035.png


.. then either 'Finish' or, if you want the leading zeros in the third column, click 'Next', select that third column in the bottom section and choose 'Text' in th top part, then 'Finish'

1592447075027.png
 
Upvote 0
Upvote 0
Or you could use Text To Columns, Delimited with the boxes for semicolon and comma checked with the colon as the Other character.
 
Upvote 0
Hi all, really appreciate everyone taking the time to look at this.

.. or this formula copied across and down to extract all parts.

20 06 18.xlsm
ABCDE
1John Murphy:Full License;01,33John MurphyFull License0133
2Mary Burke:Provisional License;0,45Mary BurkeProvisional License045
3David Bing:Full License;04,87David BingFull License0487
4Sarah James:Provisional License;05,50Sarah JamesProvisional License0550
Split Text
Cell Formulas
RangeFormula
B1:E4B1=TRIM(MID(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($A1,":",","),";",","),",",REPT(" ",100)),COLUMNS($B:B)*100-99,100))

Peter this one is working perfectly for me and is just what I need.

Many thanks.
 
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,260
Members
449,075
Latest member
staticfluids

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