4

How may I replace the carriage return (new line) in a cell with a comma and a space (", ") using the command SUBSTITUTE or any other suitable command.

As an example I want to change left cell to look like the right cell. Thank you.

enter image description here

2 Answers 2

9

char(10) is for newline, so:

=SUBSTITUTE(A1,char(10),", ")
0
2

Either, do it like Stefan said with char(10) or do the carriage return directly like:

=SUBSTITUTE(A1," <- hit Alt+Enter to make a new line inside a cell
",", ")

You also could simply copy/paste the "new line" (which i would do)... cus sometimes a "new line" <> "new line"
To do it in a clean way, i suggest this:

=SUBSTITUTE(SUBSTITUTE(A1,CHAR(13)&CHAR(10),", "),CHAR(10),", ")

If you are not sure which kind of carriage return you are facing, it will be better to check for the "2-char-new-line" or you may stick with CHAR(13) which may cause trouble later :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.