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

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
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]

[Table="width:, class:head"]
[tr=bgcolor:#FFFFFF][td=bgcolor:#5B9BD5]Column1[/td][td][/td][td=bgcolor:#70AD47]Column1.1[/td][td=bgcolor:#70AD47]Column1.2.1[/td][td=bgcolor:#70AD47]Column1.2.2[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]DATE SAMPLE OF STRING AMOUNT[/td][td][/td][td=bgcolor:#E2EFDA]DATE[/td][td=bgcolor:#E2EFDA]SAMPLE OF STRING[/td][td=bgcolor:#E2EFDA]AMOUNT[/td][/tr]
[/table]
 
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,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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