Search code examples
excelasciiplaintext

Excel newline (char(10)) copy/paste issue


I'm trying to use CHAR(10) to create some nice formatting for some scripting I am generating, but copying and pasting is not working for me. I am running Windows 8.1 atm. Here's a clarifying example. Using the formula:

="hello"&CHAR(10)&"world"

I get hello[newline]world in Excel. Copying/pasting into Notepad, I would expect

hello
world

But when I actually perform that copy/paste, I instead get:

helloworld

Now, I know that the newline is in there, because if I copy that output from notepad into this very window, I get the newline reinserted. I ultimately need to c/p out from Excel into plaintext with (visible) line breaks. Any ideas how I can accomplish this?


Solution

  • A "newline", in Windows, is typically a carriage return followed by a line feed. Those are two separate character codes: 13 & 10, respectively.

    So your formula in Excel would need to be:

    ="hello"&CHAR(13)&CHAR(10)&"world"