Experiences on the Front Lines of User Interfaces and Web Development

Insert new line in Excel formula - Mac and Windows

I ran across the need to insert a line break into a formula in Excel 2008 (I am pretty sure this works with most older versions too). My problem was simple:

What I had:

Column A Column B
1 John 12345
2 Fred 67890

What I wanted was a newline within a cell that combined other cells:

Column C
1 John
2 Fred

On Windows use the following:
=A1 & CHAR(10) & B1

On Mac use the following:
=A1 & CHAR(13) & B1

The line feed / carriage return character is different, so at least for viewing and printing, the above char codes should be used depending on your operating system.
comments powered by Disqus