Extract variable length string between first and last spaces

ExceL0ver

New Member
Joined
Apr 12, 2023
Messages
35
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hi all,

I have a column of strings of variable lengths that contain numbers and words, with spaces in between the words and numbers. Some strings contain several spaces in a row, sandwiching the part I wish to extract. I would like to extract all strings so that all characters before and including the first space are removed, and the last space and all characters after it are removed e.g.,
"4hg2 eljdg lsigh lrbdsd 3403" should be extracted as "eljdg lsigh lrbdsd"
"024nk ketnc osen enlakb jkasdl 34nh3" should be extracted as "ketnc osen enlakb jkasdl"

I've managed to remove the first part with the formula =TRIM(MID(A2,FIND(" ",A2)+1,300)) and tried to amend this formula to also remove the last part, without success. Can anyone suggest a formula that would work, please?
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
You could also use

Excel Formula:
=TEXTBEFORE(TEXTAFTER(A2," ",1)," ",-1)
 
Upvote 0
Thank you both Georgiboy and RoryA, both solutions work perfectly!
 
Upvote 0
You could also use

Excel Formula:
=TEXTBEFORE(TEXTAFTER(A2," ",1)," ",-1)
Keep forgetting about that part of the text functions, get carried away with all of the new functions and use too many.

Instead I went for the double drop...
 
Last edited:
Upvote 0
Glad that you did actually, I'd never seen the DROP function used before so I've also learnt another thing, thanks!
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,154
Members
453,021
Latest member
Justyna P

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