extract " " space from middle of a string

R

Rasoul Khoshravan

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".
 
R

Rasoul Khoshravan

thanks for reply.
I used the command you mentioned (FIND(" ",A1)) but it returns 13.
 
S

Stefi

=LEFT(A5,SEARCH(" ",TRIM(A5))-1) returns "Bob"
=MID(TRIM(A5),SEARCH(" ",TRIM(A5))+1,256) returns "1001"

Regards,
Stefi


„Rasoul Khoshravan†ezt írta:
 
R

Roger Govier

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)
 
R

Ron Rosenfeld

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
 
Top