How to use Excel CODE Function


CLEAN in excel is a text/string function. This function retrieves code from first character of a string. It retrieves Macintosh code for Mac system and ANSI system for Windows system. For example, =CODE(“B”) gives 66 as the value for Windows operating system.




  • Text: It is the text whose first character will be used and whose code will be retrieved.


  • This function was added in Excel 2000 and is available in later versions also.
  • If text argument is left blank than #VALUE error is displayed.
  • Its result comes in form of number.
  • This function is completely opposite to CHAR function.
  • CHAR function gives character value of a given code whereas CODE function gives code of a given character value.


In this example, CODE function is used to find codes of characters entered in column A and enters result in column B:

  • =CODE(“D”) gives 68 as the result,  similarly other examples are below:
Data Results
D 68
C 67
D 100
C 99
4 52
9 57
-2 45
$ 36
! 33
& 38
India 73

Leave a Comment

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