Skip to content

UNICODE

Returns the Unicode code point of the first character in a piece of text, such as 65 for "A" or 8364 for the euro sign.

Syntax

=UNICODE()

Text

Excel 2013 and later.

Try it

Edit the formula in B2 or change the inputs. The sheet recalculates as you type.

B2
A
B
C
1
Text
Code
2
Apple
65
3

B2 =UNICODE(A2) returns 65

How UNICODE works

UNICODE returns the number that identifies the first character of a text. =UNICODE("A") returns 65, =UNICODE("é") returns 233 and =UNICODE("€") returns 8364. It is the tool for finding out what an invisible or odd-looking character really is.

The one argument

text is a string or a cell reference. UNICODE reads only the first character, so =UNICODE("Apple") is 65, the code for A. To inspect another position, extract it first: =UNICODE(MID(A2,5,1)) reads the fifth character. An empty cell or empty text returns #VALUE!.

Finding hidden characters

Data from web pages, PDFs and exports often contains characters you can't see that break lookups and comparisons. A cell that looks like "Total" may start with a non-breaking space, and =A2="Total" is FALSE for no visible reason. UNICODE tells you what is there:

  • 160: a non-breaking space. TRIM does not remove it.
  • 32: an ordinary space.
  • 9: a tab. 10: a line feed. 13: a carriage return.
  • 8203: a zero-width space.

Check the first character with =UNICODE(A2), the last with =UNICODE(RIGHT(A2,1)), and use MID to check a position in between. Once you know the code, remove it with SUBSTITUTE and UNICHAR: =SUBSTITUTE(A2,UNICHAR(160),"").

Finding every odd character at once

To spot unusual characters across a cell, build an array of code points: =UNICODE(MID(A2,SEQUENCE(LEN(A2)),1)) returns one number per character. Anything above 127 is outside basic ASCII, and 160 is the usual suspect.

UNICODE and CODE

CODE returns a number from your system's character set and is limited to 255, so it can give different answers on different computers. UNICODE always follows Unicode, so =CODE("€") may return 128 where =UNICODE("€") returns 8364. Use UNICODE in new work.

The reverse

UNICHAR does the opposite and returns the character for a code point. =UNICHAR(UNICODE("€")) returns the euro sign.

Arrays

In Excel for Microsoft 365, UNICODE accepts a range and returns an array of codes, one per cell: =UNICODE(A2:A10).

Arguments

text
The text to read. Only the first character is used. An empty string returns #VALUE!.

Examples

Each example is a live sheet. Change the inputs or the formula and watch the result.

Example 1

Code of the first letter

B2 =UNICODE(A2)

Result: 65

Only the first character counts. A is code 65.

B2
A
B
C
1
Text
Code
2
Apple
65
3

B2 =UNICODE(A2) returns 65

Example 2

A currency sign

B2 =UNICODE(A2)

Result: 8364

The euro sign sits at code point 8364.

B2
A
B
C
1
Text
Code
2
€
8364
3

B2 =UNICODE(A2) returns 8364

Example 3

Spot a hidden non-breaking space

B2 =UNICODE(A2)

Result: 160

The label looks like "Total", but it begins with a non-breaking space (160). That is why a lookup for "Total" would fail.

B2
A
B
C
1
Label
First character code
2
 Total
160
3

B2 =UNICODE(A2) returns 160

Your turn.

Solve it in the sheet. Every answer is checked, with hints if you need them.

Task 1 of 2

In B2, return the Unicode code of the first character of the label in A2. Fill it down to B4.

Answer in B2, then it fills down to B4.

B2
A
B
C
D
1
Label
First character code
Starts with non-breaking space?
2
Total
3
 Total
4
€250
5

Common mistakes

  • UNICODE reads only the first character. Use MID to inspect other positions.
  • An empty cell or empty text returns #VALUE!.
  • CODE and UNICODE can disagree outside the basic range. For example, the euro sign is 8364 in UNICODE but a different number in CODE.
  • TRIM does not remove a non-breaking space (160). Replace it with SUBSTITUTE and UNICHAR(160).

Questions people ask

How do I find out what an invisible character is?

Use `=UNICODE(A2)` for the first character, or `=UNICODE(MID(A2,n,1))` for position n, and look the number up.

What is the difference between UNICODE and CODE?

CODE depends on your system's character set and stops at 255. UNICODE gives the standard Unicode number for any character.

How do I remove a non-breaking space?

Use `=SUBSTITUTE(A2,UNICHAR(160)," ")` to turn it into a normal space, then wrap in TRIM if needed.

Can UNICODE read more than one character?

No, it returns the code of the first character only. To list every code in a text, combine it with MID and SEQUENCE.

Learn UNICODE in a real sheet.

Tracks take you from the basics to modelling, one graded exercise at a time.