CODE Function in Excel

The CODE function in Excel returns a numeric code for the first character in a given text string. The CODE function in Excel is a part of text formulas.

The numeric code corresponds to the character encoding standard used by Microsoft Excel. It is typically based on the ASCII (American Standard Code for Information Interchange) or Unicode (a broader character set that includes symbols from many languages), which determines how characters are represented as numbers in Excel.

How to use CODE Function in Excel

The article in this webpage describes how to use the CODE function in Microsoft Excel with the syntax, arguments, detailed explanation, and examples step by step.

CODE Syntax

=CODE(text)

The argument of CODE function is:

  • text (required) – The text for which you want the numeric code of the first character..

CODE Examples

Let’s understand the CODE function in Excel with examples.

1. Numeric Code of the Character

The CODE function returns the numeric code of the single character. For example, in cell A2 there is only one character (“A”) and the CODE formula in cell C2 returns the corresponding numeric value (65).

=CODE(A2)

Similarly, the CODE function returns the numeric value of 66, 49 and 63 in cell C3 to C5 for the characters in cell A3 to A5 (“B”, “1”, and “?”).

Excel CODE Function Example

2. Numeric Code of the First Character

The Excel CODE function returns the numeric code of the first character only in a given text string. For example, the CODE formula in cell C2 and C3 returns the numeric code of 65 for the first character “A” in the cell A2 and A3 (“Apple” and “Arrow”).

Similarly, the CODE function in cell C4 and C5 returns the numberic code of 45 for the first character “1” in cell A4 and A5 (“100″ and “150″).

CODE Function in Excel returns the numeric code of the first character

3. Reverse of CODE function

The CHAR function returns the character for the numeric code, whereas the CODE function returns the numeric code of the first character. So, the CHAR function is the opposite or reverse of the CODE function.

In the first example, we have learned that the CODE function for character “A” returns the numeric value “65”. And in this example, you can fnd that, the CHAR function for the numeric value “65” returns character “A”. So, the CHAR function is the reverse of the CODE function.

Reverse of CODE Function in Excel

Important Notes

  • The CODE function introduced in Excel 2000 and is supported in all subsequent Excel versions.
  • In Microsoft Excel, the Windows uses the ANSI character set, while the macOS uses the Macintosh character set for text encoding.
  • The CODE function returns VALUE# error when the text argument is empty.
  • The CODE function returns the numeric code of a character, while the CHAR function returns the character corresponding to a numeric code.

Learn More

Function
Description
TEXT Function
Converts the number to text format.
TEXTAFTER Function
Get the text that occurs after the specified character or string.
TEXTBEFORE Function
Get the text that occurs before the specified character or string.
TEXTJOIN Function
Combines the text from multiple cells by adding a specified delimiter.
TEXTSPLIT Function
Splits the text by using column and row delimiters.
VALUETOTEXT Function
Converts the numeric value to text.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

How to use CODE Function in Excel

Excel Formulas (Category)

» Financial Formulas in Excel

» Logical Formulas in Excel

» Text Formulas in Excel

» Date and Time Formulas in Excel

» Lookup and Reference Formulas in Excel

» Math and Trig Formulas in Excel

» Statistical Formulas in Excel

» Engineering Formulas in Excel

» Cube Formulas in Excel

» Information Formulas in Excel

» Compatibility Formulas in Excel

» Web Formulas in Excel

Excel Tutorial Part 1 (Basic)

» Excel Basics

» Excel Home

» Excel Workbook

» Excel Template

» Excel Cell

» Excel Password

Excel Tutorial Part 2 (Format)

» Excel Clipboard

» Excel Format Font

» Excel Format Alignment

» Excel Format Number

» Excel Border

» Excel Conditional Formatting

Excel Tutorial Part 3 (Data)

» Excel Sort Data

» Excel Filter Data

» Excel Text to Columns

» Excel Data Validation

» Excel Flash Fill

» Excel Remove Duplicates

» Excel Relationships

» Excel Consolidate

» Excel What-If Analysis

» Excel Group

» Excel Charts

» Excel Table

» Excel PivotTable

Excel Tutorial Part 4 (Find)

» Excel Find and Replace

» Excel Go To

» Excel Select Objects

» Excel Selection Pane

Excel Tutorial Part 5 (Review)

» Excel Spell Check

» Excel Smart Lookup

» Excel Translate

» Excel Comments & Notes

» Excel Protect

» Excel Hide Ink

Excel Tutorial Part 6 (View)

» Excel Workbook Views

» Excel Formula Bar

» Excel Zoom

» Excel Window

» Excel Macros

Excel Tutorial Part 7 (Fx)

» Excel Formulas (Category)

» Excel Formulas (Alphabetical Order)

» Excel Errors

» Excel Name Manager

» Excel Formula Auditing

» Excel Watch Window

» Excel Calculation Options

Excel Tutorial Part 8 (Other)

» Excel Add-ins

» Excel Shortcuts