Back to Functions

CODE

Returns the numeric Unicode map value of the first character in the string provided.

TextCODE(string)

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

  1. Using CODE with a letter:

    • Example: =CODE("A")
    • Result: 65
  2. Using CODE with a cell reference:

    • Example: If A1 contains "apple", then =CODE(A1) will return 97.

Use Cases and Scenarios

  1. Text Validation: Check whether a string starts with an uppercase or lowercase letter based on its Unicode range.
  2. Custom Sorting Logic: Build formulas that sort or filter text based on character codes.
  3. 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.

Related Articles

Newsletter

More CODE examples coming soon.

We are building short, practical updates for Sheets power users.