Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default Extracting text from a string

I have a list of model descriptions in a column such as:

Accord 2.0i VTEC SE Auto HFT,VSA,17''tec
Civic 5Dr 1.8 ES Manual 17" Epsilon A

I need code to extract the first word, in this case a car model name, and
place it in the next column on its own. There is always a space after the
required word if this helps.

Also I need to extract the numbers describing the engine size ( 2.0 , 1.8
etc) and place them in column C. These could be in any position in the text
string in column A

I.e.

Column A Column B
Column C
Accord 2.0i VTEC SE Auto HFT,VSA,17''tec Accord 2.0
Civic 5Dr 1.8 ES Manual 17" Epsilon A Civic
1.8


Can you help please

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 772
Default Extracting text from a string

This can be done with functions either on string or through code, the first
should work as long is it is not 2 names, and the second will pull the size
if it has the . 2 digits before and 1 after, this can be modified for 2 on
either side.
=LEFT(A1,FIND(" ",A1)-1)
=TRIM(MID(A1,FIND(".",A1)-2,4))
this assumes data in A1 change the 4 to a 5 to get 2 digits on either side
of the .
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Alan M" wrote:

I have a list of model descriptions in a column such as:

Accord 2.0i VTEC SE Auto HFT,VSA,17''tec
Civic 5Dr 1.8 ES Manual 17" Epsilon A

I need code to extract the first word, in this case a car model name, and
place it in the next column on its own. There is always a space after the
required word if this helps.

Also I need to extract the numbers describing the engine size ( 2.0 , 1.8
etc) and place them in column C. These could be in any position in the text
string in column A

I.e.

Column A Column B
Column C
Accord 2.0i VTEC SE Auto HFT,VSA,17''tec Accord 2.0
Civic 5Dr 1.8 ES Manual 17" Epsilon A Civic
1.8


Can you help please

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Extracting text from a string

Try,

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

or if not worried about errors the simpler

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

Mike

"Alan M" wrote:

I have a list of model descriptions in a column such as:

Accord 2.0i VTEC SE Auto HFT,VSA,17''tec
Civic 5Dr 1.8 ES Manual 17" Epsilon A

I need code to extract the first word, in this case a car model name, and
place it in the next column on its own. There is always a space after the
required word if this helps.

Also I need to extract the numbers describing the engine size ( 2.0 , 1.8
etc) and place them in column C. These could be in any position in the text
string in column A

I.e.

Column A Column B
Column C
Accord 2.0i VTEC SE Auto HFT,VSA,17''tec Accord 2.0
Civic 5Dr 1.8 ES Manual 17" Epsilon A Civic
1.8


Can you help please

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Extracting text from a string

Missed the engine size:-

=MID(A1,FIND(".",A1,1)-1,3)

This works for both the examples given but is far from bullet proof.

Mike

"Alan M" wrote:

I have a list of model descriptions in a column such as:

Accord 2.0i VTEC SE Auto HFT,VSA,17''tec
Civic 5Dr 1.8 ES Manual 17" Epsilon A

I need code to extract the first word, in this case a car model name, and
place it in the next column on its own. There is always a space after the
required word if this helps.

Also I need to extract the numbers describing the engine size ( 2.0 , 1.8
etc) and place them in column C. These could be in any position in the text
string in column A

I.e.

Column A Column B
Column C
Accord 2.0i VTEC SE Auto HFT,VSA,17''tec Accord 2.0
Civic 5Dr 1.8 ES Manual 17" Epsilon A Civic
1.8


Can you help please

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default Extracting text from a string

Hello Mike

Thanks, that does work for an individual cell but when I try to copy the
formula down the column it returns the same answer in all cells rather than
the appropriate answer for that row

"Alan M" wrote:

I have a list of model descriptions in a column such as:

Accord 2.0i VTEC SE Auto HFT,VSA,17''tec
Civic 5Dr 1.8 ES Manual 17" Epsilon A

I need code to extract the first word, in this case a car model name, and
place it in the next column on its own. There is always a space after the
required word if this helps.

Also I need to extract the numbers describing the engine size ( 2.0 , 1.8
etc) and place them in column C. These could be in any position in the text
string in column A

I.e.

Column A Column B
Column C
Accord 2.0i VTEC SE Auto HFT,VSA,17''tec Accord 2.0
Civic 5Dr 1.8 ES Manual 17" Epsilon A Civic
1.8


Can you help please



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Extracting text from a string

Alan,

I had assumed your data are in Column A down but from what you describe
that's not the case your data must be in a row so in dragging it down the
formula is querying itself and so returning the same answer which should tech
me to read more carefully.

The answers the same, put the formula in A2 to look at A1 and drag right.


Mike

"Alan M" wrote:

Hello Mike

Thanks, that does work for an individual cell but when I try to copy the
formula down the column it returns the same answer in all cells rather than
the appropriate answer for that row

"Alan M" wrote:

I have a list of model descriptions in a column such as:

Accord 2.0i VTEC SE Auto HFT,VSA,17''tec
Civic 5Dr 1.8 ES Manual 17" Epsilon A

I need code to extract the first word, in this case a car model name, and
place it in the next column on its own. There is always a space after the
required word if this helps.

Also I need to extract the numbers describing the engine size ( 2.0 , 1.8
etc) and place them in column C. These could be in any position in the text
string in column A

I.e.

Column A Column B
Column C
Accord 2.0i VTEC SE Auto HFT,VSA,17''tec Accord 2.0
Civic 5Dr 1.8 ES Manual 17" Epsilon A Civic
1.8


Can you help please

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
Extracting h:mm:ss from text string Micki Excel Worksheet Functions 19 January 26th 09 05:26 PM
Extracting text from a string [email protected] Excel Worksheet Functions 8 June 2nd 08 10:09 PM
Extracting text from string Confused Excel Worksheet Functions 4 February 15th 08 03:34 PM
Extracting Info From Within A Text String nospaminlich Excel Worksheet Functions 4 January 31st 07 10:31 PM
Extracting from a text string AmyTaylor Excel Worksheet Functions 3 June 24th 05 01:34 PM


All times are GMT +1. The time now is 11:24 AM.

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

About Us

"It's about Microsoft Excel"