Extract the characters between 2 spaces in a string

Walter01

New Member
Joined
Mar 21, 2024
Messages
3
Office Version
  1. 2021
Platform
  1. Windows
Hi,

how to extract the characters between the 2nd and the 3rd space in a string? The number of these characters can vary.
For example: "spaces in a string" => returns "a".

In this thread there is a solution for the value between the 1st and the 2nd space:

=mid(a1,find(" ",a1)+1,find(" ",a1,find(" ",a1)+1)-find(" ",a1))
But I don't know how to find the position of the 3rd space.
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
How about
Fluff.xlsm
AB
1
2North West DurhamDurham
3Four Marks and Medsteadand
4Torridge and West DevonWest
Data
Cell Formulas
RangeFormula
B2:B4B2=FILTERXML("<k><m>"&SUBSTITUTE(A2," ","</m><m>")&"</m></k>","//m[3]")
 
Upvote 0
Solution
How about
Fluff.xlsm
AB
1
2North West DurhamDurham
3Four Marks and Medsteadand
4Torridge and West DevonWest
Data
Cell Formulas
RangeFormula
B2:B4B2=FILTERXML("<k><m>"&SUBSTITUTE(A2," ","</m><m>")&"</m></k>","//m[3]")
Thank you, but would it be possible to do it with simple excel commands like mid(), find(), etc.?
 
Upvote 0
Why? That just makes it harder & more messy.
Excel Formula:
=REPLACE(LEFT(A2&" ",FIND("^",SUBSTITUTE(A2&" "," ","^",3))-1),1,FIND("^",SUBSTITUTE(A2," ","^",2)),"")
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,891
Messages
6,175,229
Members
452,621
Latest member
Laura_PinksBTHFT

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