CODE function comes under the TEXT category in Excel.
CODE FUNCTION RETURNS THE ANSI/ASCII CODE OF THE GIVEN CHARACTER OR THE FIRST LETTER OF THE GIVEN STRING
ANSI, while the development of computing system defined the characters such as a to z, A TO Z, !,@ and so many other symbols with the ANSI CODE ranging from 0 to 255.
This function is specifically used if we want to compare any character on the basis of its ANSI CODE.
PURPOSE OF CODE FUNCTION IN EXCEL
CODE FUNCTION returns the ANSI/ASCII CODE of the given character or the first character of the given string.
PREREQUISITES TO LEARN CODE FUNCTION
THERE ARE A FEW PREREQUISITES WHICH WILL ENABLE YOU TO UNDERSTAND THIS FUNCTION IN A BETTER WAY.
- Basic understanding of how to use a formula or function.
- Basic understanding of rows and columns in Excel.
- Some information about the financial terms is an advantage for the use of such formulas.
- Of course, Excel software.
Helpful links for the prerequisites mentioned above What Excel does? How to use formula in Excel?
SYNTAX: CODE FUNCTION
The Syntax for the CODE function is
CHARACTER The character of which we want to find the ASCII CODE.
STRING We can pass the argument as the string too but the code would be returned only of the first letter of the string.
EXAMPLE:CODE FUNCTION IN EXCEL
Let us find out the codes of different character to learn the working of CODE FUNCTION in Excel.
The codes are following.
STEPS TO USE CODE FUNCTION
For all the examples, follow the steps to find the Code of the given character/string.STEPS:
- Put the characters in one cell each.
- Put the function =Code(character/string or the cell containing the character/string).
- For our example number 1, the function used is =CODE(G7).
- Drag down the formula through the column.
- The output will be returned as a number which will be the ASCII CODE of that particular character or first letter of the string.
- The results are shown in the picture above and in the table given below.
STEPS TO USE CODE FUNCTION USING DIRECT VALUES AND STRINGS
Let us try a few examples to see how strings are used in CODE function and how it responds.Let us find out the ASCII code of Apple, Pigeon and K by putting the direct values in the function.
EXPLANATION The picture above shows the examples were we have used the direct values into the code function as well as the Strings.
If you check the rows 1,2 and 4,5 you can see the results are matching for the APPLE and A, PIGEON and P which were intentionally taken to prove the fact that in the strings only the first letters’ codes are returned.
THE PROCEDURE OF USING THE FUNCTION HAS ALREADY BEEN DISCUSSED ABOVE.
WHAT ARE ANSI/ASCII CHARACTERS
ANSI STANDS FOR American National Standards Institute.
When computing was being developed, different methods were used to define the characters.As we all know that basic language of electronics is binary i.e. 0 and 1. Different characters were attached to certain codes using the number system like ASCII which defined the character in a coding system from 0 to 127.
A SPECIAL NUMBER WAS ASSIGNED FOR EVERY CHARACTER WHICH WE CALL AS CODE
So after this came the ANSI which included ASCII and extended it to 255 and added more character in the set.
DIFFERENCE BETWEEN CHAR AND CODE FUNCTIONS
CODE AND CHAR BOTH FUNCTIONS are related to the ANSI character set.
CHAR FUNCTION gives the CHARACTER of the given CODE as the solution whereas
CODE FUNCTION gives the ANSI CODE of the given character as the result.
Both functions act opposite to each other.
Hi, you can have a look at the video showing the usage of CODE FUNCTION.