Excel Color Code Formula

There are two ways to “excel color code formula”: the quick way you copy and the durable way you understand. This page gives you both. The exact Excel answer is above; below, we build the small mental model that makes the fix stick, so the next variation of the same problem solves itself.

Exact answer

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

=CHAR(number) and =CODE(text)

Arguments

Argumentrequired / optionalDescription
numberrequiredFor CHAR: a character code from 1 to 255.
textrequiredFor CODE: text whose first character's code you want.

Related functions

CLEANSUBSTITUTELEN
Annotated stepsExcel
1

To insert a line break, concatenate CHAR(10) between the parts: =A2 & CHAR(10) & B2.

2

Switch on Wrap Text for that cell, or the break will not be visible.

3

To diagnose a stubborn value, use =CODE(LEFT(A2,1)) on its first character.

4

Remove the identified character with SUBSTITUTE and CHAR of the same number.

Ctrl+CthenCtrl+Shift+V+Cthen+Ctrl+VPaste values · WindowsMac

Need it as an auditable file?

Ships inside the linked template — formula-driven, unlocked, audit-ready.

View template

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). The same idea underpins a lot of everyday Excel work, so the few minutes spent getting it right here pay back across every sheet you build afterwards. Treat it as a pattern, not a one-off, and it stops being something you look up and starts being something you reach for. Treat “excel color code formula” as a small repeatable workflow rather than a one-off click you hope to remember next time. Use a small test block before the live file, so any surprise in the affected formula shows up while it is still harmless. 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 turns a calculation you can defend to a CFO or an auditor into a method you can reuse, explain, and defend when the workbook leaves your screen.

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. A practical tip before you scale it up: build it once on a small block of test data, confirm the number against the tool on this page, and only then point it at your real sheet. That one habit catches almost every mistake while it is still cheap to fix, long before a wrong figure reaches a report or a colleague.

In Google Sheets

Everything above works in Google Sheets too. Excel and Sheets share the formula syntax used here; only the surrounding menus are arranged differently. That portability is deliberate — learn it once and it follows you between the two tools and across Windows and Mac. 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. Here is the takeaway for “excel color code formula”: copy the answer if you are busy, but if you have a spare few minutes, rebuild the example in Excel yourself with the tool above open beside it. That single pass — type it, run it, watch the result move when you change an input — is what turns a formula you found into a technique you trust. Keep your inputs labelled and referenced, never hard-coded, and the same sheet stays correct and auditable as it grows. Done that way, you will not need to look this up again, and you will be the person others ask.

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.