Need Help? Chat with us

How to use the Excel Code Function

The CODE Function in Excel returns a numeric code for a given character. The CODE Function can be used to understand numeric codes given to the CHAR Function as it is the reverse process of CHAR Function.

➡ What is Code Function in Excel?

The Function that accepts one argument, for the text for which you want a numeric code is called CODE Function. It returns a numeric code for the first character in a text string. The code in Excel is based on the character set used by your computer. The purpose of the CODE Function is to get the code for a character. CODE Function falls under the category of Text Functions in Excel.

➡  What is the Syntax for Code Function?

The syntax to write the CODE Function is-

=CODE (text)


Text – It is the text for which you want a numeric code

➡ How does the Code Function works?

Let’s look at the CODE function. The CODE function accepts the text and generates the numeric code for it.

➡ Example: 

Find the example given in the picture below. We have a data table with the text and we need to generate the code for each text. Simply write the formula with CODE Function and the cell of the text.

Become a "Hero at Office"• 200+ Video Lessons • Real-life Case studies • Lifetime Access


=CODE(A1) where A1 is the cell no

As shown in the picture, we have generated the codes for different types of text.

Code Function in Excel

➡ Where can Code Function be used? 

  • CODE Function can be used to abbreviate the text that contains letters in uppercase
  • To remove specific unwanted characters in Excel, you can use a formula based on the CODE Function along with SUBSTITUTE Function

Recommended Blog:

➡ Top 3 Points to Remember:

  • CODE Function returns a numeric code only for the first character in a text string
  • If you apply the CODE Function on a blank cell, then you will get a #VALUE! Error
  • The number in CODE Function can have the range only from 1 to 255
• 200+ Video Tutorials • 80 Case Studies • 3 eBooks • 2 Webinar • 24*7 Dedicated Support


➡ Conclusion:

This function is a very useful Excel Function as it helps returns the numeric code representing the character. It returns numeric value only. You can also combine this function with other functions as well.