Formula to Display Specific Line of Text in a Cell

meppwc

Well-known Member
Joined
May 16, 2003
Messages
604
Office Version
  1. 365
Platform
  1. Windows
I have the need to have a formula in B1 that looks at the contents of A1 and then displays a specific line of text that exists in A1
For Example:
A1 has the following:
REPLACE & LOANER
NEW CAD = 04/19
DELIVERY ABORTED 04/08 ON LOANER

I want cell B1 to display the contents of line 3 - "NEW CAD = 04/19"
To note. Upon creation of A1, these line are not wrapped. I seperate each line using Alt-Enter
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
How about
+Fluff 1.xlsm
AB
1
2REPLACE & LOANER NEW CAD = 04/19 DELIVERY ABORTED 04/08 ON LOANERNEW CAD = 04/19
Main
Cell Formulas
RangeFormula
B2B2=LET(a,REPLACE(A2,1,FIND(CHAR(10),A2),""),REPLACE(a,FIND(CHAR(10),a),LEN(a),""))
 
Upvote 0
Thanks Fluff.............I think we are on to something. This formula successfully displayed line 2 of cell A1
To be sure I understand the formula and how to change it for other line #'s, can you provide the same formula where as it will display line 3 ?
 
Upvote 0
How about
Excel Formula:
=LET(a,REPLACE(A2,1,FIND("^",SUBSTITUTE(A2,CHAR(10),"^",2)),""),REPLACE(a,FIND(CHAR(10),a&CHAR(10)),LEN(a),""))
 
Upvote 0
Thanks again...............I am going to have to study this much harder to understand it.
My hope is to apply it with up to 6 lines of information.
I very much appreciate what you have provided.
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0
Fluff, can I impose on your expertise one more time in relation to this? I was successful with adapting the formula to work for line 2 on down, but I have yet to figure out a way to display the 1st line. Would you mind assisting me with that?
 
Upvote 0
Hi,

A single formula option for as many lines as you want:

Book3.xlsx
ABCDEFG
1REPLACE & LOANER NEW CAD = 04/19 DELIVERY ABORTED 04/08 ON LOANERREPLACE & LOANERNEW CAD = 04/19DELIVERY ABORTED 04/08 ON LOANER   
2REPLACE & LOANER NEW CAD = 04/19 DELIVERY ABORTED 04/08 ON LOANER ADFJKASDJFK 456 678J SIEHF;ALS 23445678REPLACE & LOANERNEW CAD = 04/19DELIVERY ABORTED 04/08 ON LOANERADFJKASDJFK 456678J SIEHF;ALS23445678
Sheet1085
Cell Formulas
RangeFormula
B1:G2B1=TRIM(MID(SUBSTITUTE($A1,CHAR(10),REPT(" ",300)),COLUMNS($B1:B1)*300-299,300))
 
Upvote 0
Oh that is really cool...............thanks !!!
 
Upvote 0
If you are trying to split the text then you could also use
Excel Formula:
=LET(Txt,CHAR(10)&A2&CHAR(10),Qty,SEQUENCE(,(LEN(Txt)-LEN(SUBSTITUTE(Txt,CHAR(10),"")))-1),UNIQUE(REPLACE(LEFT(Txt,FIND("~",SUBSTITUTE(Txt,CHAR(10),"~",Qty+1))-1),1,FIND("~",SUBSTITUTE(Txt,CHAR(10),"~",Qty)),"")))
which is more robust than the method jtakw used.
 
Upvote 0

Forum statistics

Threads
1,215,218
Messages
6,123,676
Members
449,116
Latest member
HypnoFant

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top