CODE
TheCODE formula returns the numeric Unicode value of the first character in a text string. This can be useful when working with non-English characters or when attempting to identify certain characters in a text string.
- How to use
CODEformula? - Examples of using
CODEformula CODEformula not working?- Similar formulas to
CODE
Usage
Use the CODE formula with the syntax shown below, it has 1 required parameter:
=CODE(string)- string (required):
The text string for which to return the Unicode value of the first character.
Examples
Here are a few example use cases that explain how to use theCODE formula in Google Sheets.
Finding the Unicode value of a character
You can use the CODE formula to find the Unicode value of any character in a text string. For example, you could use this to determine the Unicode value of a specific letter or symbol in a range of cells.
Working with non-English characters
Because the CODE formula returns the Unicode value of a character, it can be helpful when working with non-English characters that may not be recognized by other formulas or functions.
Identifying certain characters in a string
The CODE formula can also be used to identify certain characters in a text string. For example, you could use this formula to find all instances of a specific character in a larger block of text.
Common Mistakes
CODE not working? Here are some common mistakes people make when using the CODE Google Sheets Formula:
Providing a cell reference instead of a text string
One common mistake is to provide a cell reference as the argument for the CODE formula, instead of a text string. Make sure to enclose the text string in quotation marks to avoid this error.
Providing a string with more than one character
The CODE formula only returns the code for the first character in a text string. If you provide a string with more than one character, the formula will only return the code for the first character.
Related Formulas
The following functions are similar to CODE or are often used with it in a formula:
-
CHARThe
CHARformula returns the character corresponding to the ASCII code provided. This formula is commonly used to convert a numerical value to its corresponding character in a Google Sheets cell. -
UNICHARThe
UNICHARfunction returns the Unicode character represented by the given numeric value. This is useful when working with non-Latin characters or symbols that cannot be easily typed on a keyboard. The function takes a single parameter, a number representing the Unicode value of the character to be returned. -
FINDThe
FINDformula in Google Sheets searches for a specific text within another text and returns the position of the first occurrence of the text. This formula is often used to extract a substring from a larger string or to check if a certain text exists within another text. -
SEARCHThe
SEARCHformula is used to find the position of a piece of text within a larger string of text. It returns the position of the first character of the searched text in the text being searched. This formula is case-insensitive, meaning it will find all instances of the searched text regardless of capitalization.
Learn More
You can learn more about the CODE Google Sheets function on Google Support.