ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   extract " " space from middle of a string (https://www.excelbanter.com/excel-worksheet-functions/113815-extract-space-middle-string.html)

Rasoul Khoshravan

extract " " space from middle of a string
 
a1= bob 1001
there is 10 space between bob and 1001.
I want to extract bob and 1001.
find " " command retuerns the position of last " ", in this case 13. How can
I extract only "bob".


Rasoul Khoshravan

extract " " space from middle of a string
 
thanks for reply.
I used the command you mentioned (FIND(" ",A1)) but it returns 13.

"Roger Govier" wrote in message
...
Hi

=FIND(" ",A1) returns 4
=LEFT(A1,FIND(" ",A1)-1) returns bob
--
Regards

Roger Govier


"Rasoul Khoshravan" wrote in message
...
a1= bob 1001
there is 10 space between bob and 1001.
I want to extract bob and 1001.
find " " command retuerns the position of last " ", in this case 13. How
can I extract only "bob".





Stefi

extract " " space from middle of a string
 
=LEFT(A5,SEARCH(" ",TRIM(A5))-1) returns "Bob"
=MID(TRIM(A5),SEARCH(" ",TRIM(A5))+1,256) returns "1001"

Regards,
Stefi


€˛Rasoul Khoshravan€¯ ezt Ć*rta:

a1= bob 1001
there is 10 space between bob and 1001.
I want to extract bob and 1001.
find " " command retuerns the position of last " ", in this case 13. How can
I extract only "bob".



Roger Govier

extract " " space from middle of a string
 
Hi

=FIND(" ",A1) returns 4
=LEFT(A1,FIND(" ",A1)-1) returns bob
--
Regards

Roger Govier


"Rasoul Khoshravan" wrote in message
...
a1= bob 1001
there is 10 space between bob and 1001.
I want to extract bob and 1001.
find " " command retuerns the position of last " ", in this case 13.
How can I extract only "bob".




Roger Govier

extract " " space from middle of a string
 
Hi

I wonder whether you have the non-breaking space CHAR(160) within your
string?
Try =FIND(CHAR(160),A1) and see what that produces.

If it produces a result of 4, then that is where the problem lies.
Try
=LEFT(A1,FIND(" ",SUBSTITUTE(A1,CHAR(160),""))-1)

--
Regards

Roger Govier


"Rasoul Khoshravan" wrote in message
...
thanks for reply.
I used the command you mentioned (FIND(" ",A1)) but it returns 13.

"Roger Govier" wrote in message
...
Hi

=FIND(" ",A1) returns 4
=LEFT(A1,FIND(" ",A1)-1) returns bob
--
Regards

Roger Govier


"Rasoul Khoshravan" wrote in message
...
a1= bob 1001
there is 10 space between bob and 1001.
I want to extract bob and 1001.
find " " command retuerns the position of last " ", in this case 13.
How can I extract only "bob".







Ron Rosenfeld

extract " " space from middle of a string
 
On Wed, 11 Oct 2006 10:58:17 +0900, "Rasoul Khoshravan"
wrote:

a1= bob 1001
there is 10 space between bob and 1001.
I want to extract bob and 1001.
find " " command retuerns the position of last " ", in this case 13. How can
I extract only "bob".


You could download and install Longre's free morefunc.xll add-in from:
http://xcell05.free.fr/

and then use the formula:

=REGEX.MID(A1,"\w+") to extract the first word
=REGEX.MID(A1,"\w+",2) to extract the second

It should not matter what kind of spaces are between the two "words".


--ron


All times are GMT +1. The time now is 12:13 PM.

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