Only showing text before 5th carriage return

yalane1103

New Member
Joined
Jan 25, 2022
Messages
5
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
  2. Mobile
  3. Web
Hi All,

First time poster, so please be gentle. :)

I have a cell that has 30 lines of status updates (broken by carriage returns). I only want to show the first 5 lines of status updates and delete the rest of the text. HELP! I know how to search for carriage return and show a specific amount of characters before or after the return, but I don't want the text to be cutoff mid-word or mid-sentence, so I want it to end at a carriage return. Just formulas please.

Thanks!
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Hi & welcome to MrExcel.
How about
Excel Formula:
=LEFT(A2,FIND("^",SUBSTITUTE(A2,CHAR(10),"^",5))-1)
 
Upvote 0
will you alwasy have at least 5 linefeeds in the cell?
 
Upvote 0
Does that formula work for cells with 5 or more linefeeds?
Also what should happen if there are less than 5?
 
Upvote 0
Does that formula work for cells with 5 or more linefeeds?
Also what should happen if there are less than 5?
oh! so sorry. yes it works when there are more than 5 returns. i thought the cells i was trying it on had more than 5 returns but they didn't.

but to your point, there are cases when there will NOT be 5 returns, and in those cases, i want it to return all the text. thank you!
 
Upvote 0
In that case try
Excel Formula:
=IFERROR(LEFT(A2,FIND("^",SUBSTITUTE(A2,CHAR(10),"^",5))-1),A2)
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,723
Messages
6,174,108
Members
452,544
Latest member
aush

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