The CODE function in Google Sheets returns the numeric Unicode value of the first character in a given string. It's useful for text analysis, data validation, and sorting logic that depends on character codes rather than raw text. Dive into our comprehensive guide to master its application.
Parameters
string: The string whose first character's Unicode value you want to retrieve.
Step-by-Step Tutorial
-
Using
CODEwith a letter:- Example:
=CODE("A") - Result:
65
- Example:
-
Using
CODEwith a cell reference:- Example: If
A1contains"apple", then=CODE(A1)will return97.
- Example: If
Use Cases and Scenarios
- Text Validation: Check whether a string starts with an uppercase or lowercase letter based on its Unicode range.
- Custom Sorting Logic: Build formulas that sort or filter text based on character codes.
- Data Cleaning: Identify hidden or non-printable characters at the start of imported text.
Related Functions
CHAR: Converts a Unicode number into the corresponding character.UNICODE: Returns the Unicode value of the first character in a string.UNICHAR: Returns the character associated with a given Unicode value.