- Why does CODE return a number instead of the character itself?
- CODE is designed to give you the underlying numeric representation of a character, which is useful for comparisons, sorting, or creating custom encoding schemes. To get the character back, use CHAR with the number you obtained.
- Can CODE handle Unicode characters like emojis?
- In Excel, CODE returns the Unicode code point for any character, including emojis, as long as the font supports it. Google Sheets, however, only returns the first 255 code points; for full Unicode support use the UNICODE function.
- What happens if I pass a number like 123 to CODE?
- Excel coerces the number to the text string "123" and then returns the code for the first character "1" (which is 49). If you need the code for the numeric value itself, convert the number to text first with TEXT.
- Is there a way to get the code for every character in a cell without writing multiple formulas?
- Yes. In Excel you can use an array formula such as =CODE(MID(A2,ROW(INDIRECT("1:"&LEN(A2))),1)) and then press Ctrl+Shift+Enter. In Google Sheets, wrap the same expression with ARRAYFORMULA.