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

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
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
A
B
1
Hello1


Hello2
Hello1
Hello2
2

<tbody>
</tbody>

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,214,929
Messages
6,122,315
Members
449,081
Latest member
tanurai

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