Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Adam Cole
 
Posts: n/a
Default Extract the first word from a cell?

I'm using Excel 2003 and need to return the first eight characters from a cell.

The "Left" function is fine for this but where the first word is less than
eight characters I only want to extract the first word and "left" includes
the start of the second word!

Can anyone help?
  #2   Report Post  
Frank Kabel
 
Posts: n/a
Default

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

--
Regards
Frank Kabel
Frankfurt, Germany

Adam Cole wrote:
I'm using Excel 2003 and need to return the first eight characters
from a cell.

The "Left" function is fine for this but where the first word is less
than eight characters I only want to extract the first word and
"left" includes
the start of the second word!

Can anyone help?



  #4   Report Post  
JE McGimpsey
 
Posts: n/a
Default

Make that:

=LEFT(A1,MIN(IF(ISNUMBER(FIND(" ",A1)),FIND(" ",A1)-1,8)))


In article ,
JE McGimpsey wrote:

One way:

=LEFT(A1,MIN(IF(ISNUMBER(FIND(" ",A1)),FIND(" ",A1),8)))

  #5   Report Post  
Frank Kabel
 
Posts: n/a
Default

Hi J.E. maybe with error checking:
=LEFT(A1,FIND(" ",A1&" ")-1)
or
=LEFT(A1,MAX(8,FIND(" ",A1&" ")-1))

--
Regards
Frank Kabel
Frankfurt, Germany

JE McGimpsey wrote:
Make that:

=LEFT(A1,MIN(IF(ISNUMBER(FIND(" ",A1)),FIND(" ",A1)-1,8)))


In article ,
JE McGimpsey wrote:

One way:

=LEFT(A1,MIN(IF(ISNUMBER(FIND(" ",A1)),FIND(" ",A1),8)))





  #6   Report Post  
JE McGimpsey
 
Posts: n/a
Default

I like the approach, but neither of those work.

Both, if the first space in the cell is after character 9 (or there is
no space) return a too-long string.

You could fix the first with

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

The second one can be fixed by using MIN instead of MAX.

=LEFT(A1,MIN(8,FIND(" ",A1&" ")-1))

In article ,
"Frank Kabel" wrote:

Hi J.E. maybe with error checking:
=LEFT(A1,FIND(" ",A1&" ")-1)
or
=LEFT(A1,MAX(8,FIND(" ",A1&" ")-1))

  #7   Report Post  
Frank Kabel
 
Posts: n/a
Default

Hi J.E.
thanks for the correction. The first approach wans't meant to restrict the
output to only 8 characters but only to prevent an error if no space is
found.
the second one: Shame on me to mess up MIN and MAX :-)

--
Regards
Frank Kabel
Frankfurt, Germany

JE McGimpsey wrote:
I like the approach, but neither of those work.

Both, if the first space in the cell is after character 9 (or there is
no space) return a too-long string.

You could fix the first with

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

The second one can be fixed by using MIN instead of MAX.

=LEFT(A1,MIN(8,FIND(" ",A1&" ")-1))

In article ,
"Frank Kabel" wrote:

Hi J.E. maybe with error checking:
=LEFT(A1,FIND(" ",A1&" ")-1)
or
=LEFT(A1,MAX(8,FIND(" ",A1&" ")-1))



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I use word wrap in a merged cell in excel 2000? PartnersHC Excel Discussion (Misc queries) 4 October 18th 09 10:02 PM
Extract hyperlink string from excel cell Ryan Sapien Links and Linking in Excel 1 January 20th 05 12:24 AM
Copy Word table into Excel cell by cell hg Excel Discussion (Misc queries) 3 December 15th 04 04:43 PM
Paste rows of numbers from Word into single Excel cell BecG Excel Discussion (Misc queries) 1 December 8th 04 04:55 PM
vlookup to extract part cell content excelFan Excel Discussion (Misc queries) 2 December 5th 04 08:45 AM


All times are GMT +1. The time now is 06:07 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"