ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   extract text between two spaces (https://www.excelbanter.com/excel-discussion-misc-queries/131378-extract-text-between-two-spaces.html)

Anthony

extract text between two spaces
 
how do i use the mid function to extract the "word" between the second and
third spaces or between the fourth and fifth spaces or even between the
second and fourth spaces?

thanks in advance

ExcelBanter AI

Answer: extract text between two spaces
 
Hi there! To extract text between two spaces using the MID function in Excel, you can follow these steps:
  1. Determine the position of the spaces: To extract the "word" between the second and third spaces, you need to know the position of the second and third spaces. You can use the FIND function to locate the positions of the spaces. For example, to find the position of the second space in cell A1, you can use the formula:
    Formula:

    =FIND(" ",A1,FIND(" ",A1)+1

  2. Use the MID function: Once you know the positions of the spaces, you can use the MID function to extract the text between them. The syntax of the MID function is: =MID(text, start_num, num_chars). In this case, the "text" argument is the cell containing the text you want to extract from, the "start_num" argument is the position of the second space plus 1 (to start extracting after the second space), and the "num_chars" argument is the difference between the positions of the third space and the second space (to extract the text between them). The formula would look like this:
    Formula:

    =MID(A1,FIND(" ",A1,FIND(" ",A1)+1)+1,FIND(" ",A1,FIND(" ",A1,FIND(" ",A1)+1))-FIND(" ",A1,FIND(" ",A1)+1)) 

  3. Repeat for other positions: To extract the "word" between the fourth and fifth spaces or between the second and fourth spaces, you can follow the same steps, but adjust the positions of the spaces in the formulas accordingly.

Stefi

extract text between two spaces
 
=SUBSTITUTE(A1," word","")

extracts it from anywhere. Does it suit your needs?

Regards,
Stefi


€˛anthony€¯ ezt Ć*rta:

how do i use the mid function to extract the "word" between the second and
third spaces or between the fourth and fifth spaces or even between the
second and fourth spaces?

thanks in advance


Ron Rosenfeld

extract text between two spaces
 
On Mon, 19 Feb 2007 22:19:21 -0800, anthony
wrote:

how do i use the mid function to extract the "word" between the second and
third spaces or between the fourth and fifth spaces or even between the
second and fourth spaces?

thanks in advance


I would use a different method (regular expressions), but to use the MID
function, where SpaceNum1 is the number of the first space (e.g. 2 for second),
and SpaceNum2 is the number of the second space, you can use:

=MID(A1,FIND(CHAR(1),SUBSTITUTE(A1," ",CHAR(1),
SpaceNum1))+1,FIND(CHAR(1),SUBSTITUTE(A1," ",
CHAR(1),SpaceNum2))-FIND(CHAR(1),SUBSTITUTE(
A1," ",CHAR(1),SpaceNum1))-1)


--ron

Anthony

extract text between two spaces
 

thanks ron works perfect
(and i was able to modify it slightly)

Ron Rosenfeld

extract text between two spaces
 
On Tue, 20 Feb 2007 04:26:05 -0800, anthony
wrote:


thanks ron works perfect
(and i was able to modify it slightly)



Glad to help. Thanks for the feedback
--ron


All times are GMT +1. The time now is 06:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com