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.
Master the fundamentals of Excel UNICODE function
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.
Supports full Unicode range (1-1114111)
Returns code for first character only
Returns codes for emojis
Inverse of UNICHAR function
Function-specific parameters
Function-specific return type
Analyze Unicode characters and codes
Work with Unicode encoding
Process and analyze emoji characters
Analyze international character codes
Exact matching required
Returns numeric position
Handles missing text gracefully
=UNICODE(text)The text string for which you want the Unicode code of the first character
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)
Get Unicode code of character
Returns Unicode 65 for uppercase letter 'A'
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 SubAnalyze 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 FunctionAnalyze Unicode characters and codes
Get Unicode codes for emojis
Work with Unicode encoding
Check character Unicode ranges
UNICODE with empty cell returns #VALUE!
=IF(A1="", "", UNICODE(A1))Solution: Check for empty cells: =IF(A1="", "", UNICODE(A1)) or use IFERROR.
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))
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.
UNICODE requires Excel 2013 or later
=CODE(A1) for older versionsSolution: Use CODE for older Excel versions, or upgrade to Excel 2013+. CODE only supports ASCII range.