In Excel: use =CHAR(number) to produce a character from its code and =CODE(text) to read the code of one — CHAR(10) is a line break, CHAR(160) a non-breaking space.
On this page8
Syntax
Arguments
| Argument | required / optional | Description |
|---|---|---|
number | required | For CHAR: a character code from 1 to 255. |
text | required | For CODE: text whose first character's code you want. |
Related functions
To insert a line break, concatenate CHAR(10) between the parts: =A2 & CHAR(10) & B2.
Switch on Wrap Text for that cell, or the break will not be visible.
To diagnose a stubborn value, use =CODE(LEFT(A2,1)) on its first character.
Remove the identified character with SUBSTITUTE and CHAR of the same number.
What this does
CHAR turns a number into the character it represents and CODE does the reverse. They matter for two everyday jobs. Inserting a line break inside a formula-built string requires CHAR(10) on Windows, since you cannot type Alt+Enter inside a formula — and the cell must have Wrap Text switched on or the break stays invisible. And diagnosing invisible characters requires CODE: pointing it at the first character of a stubborn value tells you exactly what is there, which is usually 160 (non-breaking space) or 10 (line feed). Most people learn this as a sequence of clicks and forget it by next week; learning it as a pattern instead is what lets you apply it to the next, slightly different version of the problem without starting from scratch. That is the difference this page is trying to make. For “char function in excel”, the reliable version is a short checking loop, not just the first command that appears to work. Run it on a deliberately small range first, watch how the affected formula change, and only then apply the same setup to the full sheet. When a formula is involved, keep the inputs labelled beside it, reference cells instead of typing values, and apply number formatting only after the result checks out. That is what makes a text operation that turns messy entries into clean, usable data useful in real work: repeatable, auditable, and not dependent on memory or luck.
A worked example
Building a multi-line address in one cell: =A2 & CHAR(10) & B2 & CHAR(10) & C2, with Wrap Text enabled on the cell. Diagnosing a value that will not match: =CODE(LEFT(A2,1)) returning 160 identifies a non-breaking space. Removing it once identified: =SUBSTITUTE(A2, CHAR(160), " "). CHAR(10) is the only way to build a multi-line cell from a formula, and CODE is the only way to identify what invisible character is breaking a match. Check the referenced cells, argument order and result type in your workbook. Start with the worked example before changing an input, then compare the changed result with the calculation you expected. An error value or a result of a different type is a reason to inspect the inputs and arguments.
In Google Sheets
Google Sheets support for this task has not been verified. Check the function, arguments and workflow in the target product before transferring the example. Matching formula notation does not establish identical behaviour. Nothing on this page is behind a login or a download: the exact answer is at the top, and the detail below it is there for when you need it. That is the whole promise here — the answer first, and just enough context to make it stick. For “char function in excel”, keep the input cells and the result visible while you check the formula in Excel. Follow the worked example and change one input at a time. The steps explain the workbook calculation; this page does not run a live calculator for that task.
Common mistakes
- Using CHAR(10) without enabling Wrap Text, which makes the line break invisible and looks like the formula failed.
- Using CHAR(10) on a Mac where CHAR(13) is expected in some contexts; test which one your file needs.
- Passing 0 or a number above 255 to CHAR, which returns
#VALUE!.
Frequently asked questions
How do I add a line break in a formula?
Concatenate CHAR(10): =A2 & CHAR(10) & B2, then turn on Wrap Text for the cell.
How do I find out what an invisible character is?
=CODE(LEFT(A2,1)) returns its number. 160 is a non-breaking space, 10 a line feed, 9 a tab.
Why does my CHAR(10) not show a new line?
Wrap Text is off. The break is in the value; the cell is just not rendering it.