Example 1
Code of the first letter
B2 =UNICODE(A2)
Result: 65
Only the first character counts. A is code 65.
B2 =UNICODE(A2) returns 65
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()
Excel 2013 and later.
Try it
Edit the formula in B2 or change the inputs. The sheet recalculates as you type.
B2 =UNICODE(A2) returns 65
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.
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!.
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:
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),"").
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.
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.
UNICHAR does the opposite and returns the character for a code point. =UNICHAR(UNICODE("€")) returns the euro sign.
In Excel for Microsoft 365, UNICODE accepts a range and returns an array of codes, one per cell: =UNICODE(A2:A10).
#VALUE!.Each example is a live sheet. Change the inputs or the formula and watch the result.
Example 1
B2 =UNICODE(A2)
Result: 65
Only the first character counts. A is code 65.
B2 =UNICODE(A2) returns 65
Example 2
B2 =UNICODE(A2)
Result: 8364
The euro sign sits at code point 8364.
B2 =UNICODE(A2) returns 8364
Example 3
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 =UNICODE(A2) returns 160
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.
#VALUE!.Use `=UNICODE(A2)` for the first character, or `=UNICODE(MID(A2,n,1))` for position n, and look the number up.
CODE depends on your system's character set and stops at 255. UNICODE gives the standard Unicode number for any character.
Use `=SUBSTITUTE(A2,UNICHAR(160)," ")` to turn it into a normal space, then wrap in TRIM if needed.
No, it returns the code of the first character only. To list every code in a text, combine it with MID and SEQUENCE.
Tracks take you from the basics to modelling, one graded exercise at a time.