CODE Function – Google Sheets

The CODE function in Google Sheets to finds the Unicode value of the first character in a given text string. This function can be helpful when working with different character sets, encoding systems, or performing specific operations based on character codes.

You can use CODE in a variety of ways. For example, you could use it to:

  • Convert text to numbers
  • Validate data
  • Perform calculations based on character codes
  • Create custom functions

Syntax

The syntax for the CODE function is as follows:

=CODE(text)

text – The text string you want to find the Unicode value for.

Related Functions

CHAR – Convert a Unicode number to a character

UNICHAR – Convert a Unicode number to a character (Same as CHAR)

UNICODE – Return the Unicode value of the first character in a text string (same as this page’s function)

Example 1 – Find the Unicode Character for an Arrow

First, let’s say your spreadsheet has an arrow character such as . You can use the CODE function to find its Unicode value.

=CODE("↑")

This would return 8593, which is the Unicode value for the “” symbol.

Example 2 – Check if a Letter is Upper-Case

To validate data, you could use the CODE function to check if a value is within a specific range of Unicode values. For example, the following formula would return TRUE if the value in cell A1 is a capital letter:

=IF(AND(CODE(A1) > 64, CODE(A1) < 91),TRUE,FALSE)

Using the CODE function to check case
Checking Case

Use an Add-On for Unicode Characters

Use the Insert Special Characters add-on to find Unicode characters by searching instead of using codes.

Live Examples in Google Sheets

Make a copy of this Google Sheet to use the examples in your own spreadsheet.

Conclusion

The CODE function is a powerful tool that you can use to manipulate text in Google Sheets. If you need to work with different character sets or encoding systems, or if you need to perform specific operations based on character codes, the CODE function is a great option.

Leave a Comment