extract text from string

LFKim2018

Active Member
Joined
Mar 24, 2018
Messages
267
how could I extract to 3 columns the following string format?
DATE SAMPLE OF STRING AMOUNT

first text is before the first occurrence of the space
2nd text is between the 1st space and the last space
3rd text is after the last space

say string is at A2
B2 = DATE
C2 = SAMPLE OF STRING (can contain more than 3 words)
D2 = AMOUNT

many many thanks
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
I got the first and the last part ---
the only problem now is to extract the MID -
between the first space and the last space

many thanks
 
Upvote 0
the 1st text:
=LEFT(A2, SEARCH(" ",A2,1)-1)

the 3rd text:
=RIGHT(A2,LEN(A2)-FIND("@",SUBSTITUTE(A2," ","@",LEN(A2)-LEN(SUBSTITUTE(A2," ",""))),1))
whew... is there a shorter formula than this?
 
Upvote 0
if you are able to use PowerQuery (Get&Transform) try this:
Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
    #"Split Column by Delimiter" = Table.SplitColumn(Source, "Column1", Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, false), {"Column1.1", "Column1.2"}),
    #"Split Column by Delimiter1" = Table.SplitColumn(#"Split Column by Delimiter", "Column1.2", Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, true), {"Column1.2.1", "Column1.2.2"})
in
    #"Split Column by Delimiter1"[/SIZE]

Column1Column1.1Column1.2.1Column1.2.2
DATE SAMPLE OF STRING AMOUNTDATESAMPLE OF STRINGAMOUNT
 
Last edited:
Upvote 0
the 3rd text:
=RIGHT(A2,LEN(A2)-FIND("@",SUBSTITUTE(A2," ","@",LEN(A2)-LEN(SUBSTITUTE(A2," ",""))),1))
whew... is there a shorter formula than this?
Yes...

=TRIM(RIGHT(SUBSTITUTE(A2," ",REPT(" ",99)),99))
 
Upvote 0

Forum statistics

Threads
1,216,093
Messages
6,128,784
Members
449,468
Latest member
AGreen17

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