Search code examples
google-sheetsgoogle-docs

Remove line break within cell google spreadsheet


Is there an easy way to remove the line breaks within each cell?Spreadsheet Image

Each cell on column E, has extra line that I am having to manually remove, any easy to remove all.


Solution

  • How about following sample? This sample supposes that the line break is \r\n and \n.

    FLow :

    1. Retrieve the information of line break.
    2. If the line break is \r\n, when the number of \r\n is more than 2, it is modified to char(10).

    Sample :

    =IF(REGEXMATCH(E1, "\r\n"),REGEXREPLACE(E1, "(\r\n){2,}", char(10)),REGEXREPLACE(E1, "(\n){2,}", char(10)))
    

    Result :

    enter image description here

    If you want to remove all of the line break, you can use =CLEAN(A1). In this case, the result of the result sheet becomes sample1sample2sample3sample4sample5.

    If this was not helpful for you, I'm sorry.