UNICODE

Text Functions
(4.6/5)

Returns the number (code point) corresponding to the first character of the text string. Supports full Unicode character set. Essential for character analysis, encoding work, and understanding Unicode character codes in Excel.

Interactive Formula Tester

=UNICODE("A")

Complete Theory & Understanding

Master the fundamentals of Excel UNICODE function

Core Concept

The UNICODE function returns the Unicode code point (number) for the first character in a text string. It's the inverse of UNICHAR function and extends beyond CODE by supporting the full Unicode character set, including emojis, international characters, and extended symbols. Essential for character encoding, analysis, and Unicode processing.

Why Use UNICODE?

  • Analyze Unicode characters and codes
  • Work with Unicode encoding
  • Process and analyze emoji characters
  • Analyze international character codes

Key Characteristics

Full Unicode Support

Supports full Unicode range (1-1114111)

UNICODE("😀") returns 128512

First Character Only

Returns code for first character only

UNICODE("ABC") returns 65 (for "A")

Emoji Support

Returns codes for emojis

UNICODE("😀") = 128512

UNICHAR Inverse

Inverse of UNICHAR function

UNICODE(UNICHAR(65)) returns 65

Function Anatomy

=UNICODE(parameters...)
Required
Parameters:

Function-specific parameters

Returns
Return Value:

Function-specific return type

Primary Use Cases

Character Analysis

Analyze Unicode characters and codes

Encoding Work

Work with Unicode encoding

Emoji Processing

Process and analyze emoji characters

International Text

Analyze international character codes

Theory Summary

Precise

Exact matching required

Position-Based

Returns numeric position

Error-Safe

Handles missing text gracefully

Syntax & Parameters

=UNICODE(text)
Required
text:

The text string for which you want the Unicode code of the first character

Returns
Return Value:

Unicode code point (number) of the first character

Description: Returns the Unicode code point for the first character in a text string (supports full Unicode range)

Interactive Examples

Basic Unicode Code

Get Unicode code of character

""A""
=UNICODE("A")
65

Returns Unicode 65 for uppercase letter 'A'

VBA Implementation & Automation

Basic UNICODE in VBA

Simple VBA implementation of UNICODE function

' Basic UNICODE in VBA
Range("B1").Value = Application.WorksheetFunction.Unicode(Range("A1").Value)

' Using VBA Unicode function
Dim text As String
text = "A"
Dim unicodeCode As Long
unicodeCode = Application.WorksheetFunction.Unicode(text)
Debug.Print unicodeCode ' Output: 65

' Get codes for multiple characters
Sub GetUnicodeCodes()
    Dim cell As Range
    For Each cell In Range("A1:A10")
        If Not IsEmpty(cell.Value) Then
            Dim firstChar As String
            firstChar = Left(cell.Value, 1)
            cell.Offset(0, 1).Value = Application.WorksheetFunction.Unicode(firstChar)
        End If
    Next cell
End Sub

' Get emoji Unicode codes
Sub GetEmojiCodes()
    Range("B1").Value = Application.WorksheetFunction.Unicode("😀") ' 128512
    Range("B2").Value = Application.WorksheetFunction.Unicode("😁") ' 128513
    Range("B3").Value = Application.WorksheetFunction.Unicode("😂") ' 128514
End Sub

Advanced Unicode Analysis

Analyze Unicode characters and categorize

' Function to get Unicode code safely
Function GetUnicodeSafe(text As String) As Variant
    On Error Resume Next
    If Len(text) > 0 Then
        GetUnicodeSafe = Application.WorksheetFunction.Unicode(text)
    Else
        GetUnicodeSafe = "#VALUE!"
    End If
    On Error GoTo 0
End Function

' Get all Unicode codes in string
Function GetAllUnicodeCodes(text As String) As String
    Dim i As Integer
    Dim result As String
    result = ""
    For i = 1 To Len(text)
        Dim char As String
        char = Mid(text, i, 1)
        If i > 1 Then result = result & ", "
        result = result & Application.WorksheetFunction.Unicode(char)
    Next i
    GetAllUnicodeCodes = result
End Function

' Categorize character by Unicode range
Function CategorizeUnicode(text As String) As String
    Dim code As Long
    code = Application.WorksheetFunction.Unicode(Left(text, 1))
    
    If code >= 48 And code <= 57 Then
        CategorizeUnicode = "Digit"
    ElseIf code >= 65 And code <= 90 Then
        CategorizeUnicode = "Uppercase"
    ElseIf code >= 97 And code <= 122 Then
        CategorizeUnicode = "Lowercase"
    ElseIf code >= 128512 And code <= 128591 Then
        CategorizeUnicode = "Emoji"
    ElseIf code >= 19968 And code <= 40959 Then
        CategorizeUnicode = "CJK"
    Else
        CategorizeUnicode = "Other"
    End If
End Function

Business Applications

Character Analysis

Analyze Unicode characters and codes

=UNICODE(A1)

Emoji Processing

Get Unicode codes for emojis

=UNICODE("😀")

Encoding Work

Work with Unicode encoding

=UNICODE(A1)

Character Validation

Check character Unicode ranges

=IF(UNICODE(A1)>=19968, IF(UNICODE(A1)<=40959, "CJK", "Other"), "Other")

Common Issues & Solutions

Empty Cell

UNICODE with empty cell returns #VALUE!

=IF(A1="", "", UNICODE(A1))

Solution: Check for empty cells: =IF(A1="", "", UNICODE(A1)) or use IFERROR.

Multiple Characters

UNICODE only returns code for first character

=UNICODE(MID(A1, 2, 1))

Solution: This is expected behavior. Use MID with UNICODE to get codes for other positions: =UNICODE(MID(A1, 2, 1))

Character Not Recognized

Some characters may not have valid Unicode codes

=UNICODE(A1)

Solution: Ensure character is valid Unicode. Most characters have codes, but some control characters may cause issues.

Excel Version

UNICODE requires Excel 2013 or later

=CODE(A1) for older versions

Solution: Use CODE for older Excel versions, or upgrade to Excel 2013+. CODE only supports ASCII range.

Performance Tips & Best Practices

⚡ Performance Optimization

  • Use UNICODE efficiently for character analysis
  • Combine UNICODE with IF for character validation
  • Cache UNICODE results when used multiple times
  • Consider CODE for ASCII range characters (1-255)

🎯 Best Practices

  • Remember UNICODE only returns code for first character
  • Use UNICODE for characters beyond ASCII range
  • Combine with MID to get codes for other positions
  • Document UNICODE usage for character analysis

💡 Pro Tips

  • UNICODE supports full Unicode range vs CODE (ASCII only)
  • UNICODE("😀")=128512, UNICODE("€")=8364
  • Use UNICODE with UNICHAR: UNICODE(UNICHAR(65)) returns 65
  • UNICODE is available in Excel 2013 and later