View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joeu2004 joeu2004 is offline
external usenet poster
 
Posts: 2,059
Default find beginning of line to first space?

On Apr 27, 12:15*pm, Lance wrote:
I have some cells that look like this
1 One
02 Two
003 Three
4 Four
000005 Five
and I am looking for a way to cut and paste the number
into a new column. *I am guessing I should search and
select anything from the beginning of the line to the
first space. *I could then cut this value and place it
elsewhere.


You could do that. See below. But perhaps the easiest way is to use
the Text To Column feature. In XL2003, click on Data Text To
Column, select an appropriate delimiter, click Next to move along, and
in the last menu, select Skip for the second column and select where
you would like the result.

If you want to retain the leading zeros, either mark the column as
Text before clicking Finish, or afterwards choose an appropriate
Custom format, e.g. 000000.

As for a function, you might use the following paradigm:

=LEFT(A1,FIND(" ",A1)-1)

or

=--LEFT(A1,FIND(" ",A1)-1)

The first form produces text, which preserves leading zeros. The
second form produces numeric results, which would require a Custom
format to display leading zeros.

Caveat: The blanks you see might be non-breaking spaces (HTML  )
instead of normal spaces. In that case, replace " " with CHAR(160).