top of page

How to Return the ASCII Number for Every Character in a Cell


How to Return the ASCII Number for Every Character in a Cell in Excel

The formulas below will take any text input and return the ASCII value of each character that comprises that string.

Contents:


Formulas

For every ASCII number listed in a single cell (as in the picture above), you can use the following formula:

=TEXTJOIN(" ",,CODE(MID(string, SEQUENCE(LEN(string)), 1)))

For a vertically spilled dynamic array use the following formula:

=CODE(MID(string, SEQUENCE(LEN(string)), 1))

And for a horizontally spilled dynamic array use the following:

=CODE(MID(string, SEQUENCE(1, LEN(string)), 1))

Explanation

These functions can all be broken up into five main parts from the five functions used: LEN, SEQUENCE, MID, CODE, and TEXTJOIN.


We'll use the formula that combines all of the characters into a single cell, and the string "Sample".

Formula to convert cell to ASCII

The first part of the formula is the LEN function that returns the number of characters in a given cell. In this case, the number 6.


Create sequence of numbers to match the length of a cell

This length number is then fed to the SEQUENCE function, which generates a dynamic array. The size of which matches the number of characters in the cell.




split up a cell by individual characters

The next step is using the MID function. This function, combined with the array from the SEQUENCE function, will separate a cell into individual characters.


From there, all that is left to do is to use the CODE function to convert the separated characters into ASCII and concatenate them into a single cell using the TEXTJOIN function.


In this formula the delimiter used is a space, " ", but a comma (or any other symbol) could also be used.

Formula to return ASCII numbers from text in excel



bottom of page