View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Jacob Skaria Jacob Skaria is offline
external usenet poster
 
Posts: 8,520
Default Select text before carriage return

To extract the first word
=LEFT(A1,FIND(CHAR(10),A1)-1)

second word
=MID(A1,FIND(CHAR(10),A1)+1,FIND(CHAR(10),A1,FIND( CHAR(10),A1)+1)-FIND(CHAR(10),A1)-1)

third word
=TRIM(RIGHT(SUBSTITUTE(A1,CHAR(10),REPT(CHAR(32),L EN(A1))),LEN(A1)))

It is better to try out this UDF (User Defined function). From workbook
launch VBE using Alt+F11. From menu Insert a Module and paste the below
function.Close and get back to workbook and try the below formula.

Function GetString(strData As String, intWord As Integer)
GetString = Split(strData, Chr(10))(intWord - 1)
End Function


Use this formula with your data in cell A1. The second parameter is the word
number

=GetString(A1,1)
=GetString(A1,2)
=GetString(A1,3)



If this post helps click Yes
---------------
Jacob Skaria


"jellyroller" wrote:

I am looking to develop a formula that selects the text before/after a
carriage return in a cell. For example if cell A1 has the text below in

Show name
Venue
Time

I want to find out how I can get a formula which shows me the second line
only (i.e. Venue) or the last line or the first depending on where I am using
it. ANy ideas? Im guessing it will be a left / right formula but cant quite
figure it out