Removing Consecutive Line Breaks

FrankenBob

New Member
Joined
Aug 5, 2015
Messages
2
Morning,

Apologies if this has already been asked, but I couldn't find anything related.

I am trying to replace instances of double line breaks with a single line break.

So far I am trying the following:
Code:
=IFERROR(SUBSTITUTE(A1,CHAR(10)&CHAR(10),CHAR(10)),A1)

However, I get the results below (in 'B1'). I am looking for my formula to remove the additional carriage return in Cell 'A1' (so the result should look like 'A2') or if there are no double carriage returns return the cell unaltered.

Picture1_1.png


Any help would be greatly appreciated.

Cheers
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
You don't need the IFERROR part. The cells in column B must be formatted with the "Wrap Text" button.
SUBSTITUTE(A1,CHAR(10),CHAR(13))
 
Upvote 0
You don't need the IFERROR part. The cells in column B must be formatted with the "Wrap Text" button.
SUBSTITUTE(A1,CHAR(10),CHAR(13))

Thanks for the quick reply, unfortunately; though a little more elegant, your formula returns the same as mine, even with the 'Wrap Text' button enabled.

Unless I am doing something wrong?

I need to preserve instances of a single carriage return.

Thanks for any help.
 
Upvote 0
[TABLE="class: grid, width: 200"]
<tbody>[TR]
[TD][/TD]
[TD]A
[/TD]
[TD]B
[/TD]
[/TR]
[TR]
[TD]1
[/TD]
[TD]Hello1


Hello2
[/TD]
[TD]Hello1
Hello2
[/TD]
[/TR]
[TR]
[TD]2
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

My result looks like the table above. (The lines below or above, depending on the cell alignment, are empty)
 
Last edited:
Upvote 0
This formula will handle up to 12 consecutive Line Feed characters (if you need to handle more than that, let me know)...

=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,REPT(CHAR(10),5),CHAR(10)),REPT(CHAR(10),3),CHAR(10)),REPT(CHAR(10),3),CHAR(10)),REPT(CHAR(10),2),CHAR(10))
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

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