CODE in WPS Spreadsheet: Inspect the First Character of Text
Inspect a text string’s first character in WPS Spreadsheet with ASCII code checks, position helpers and blank-input guards.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
Quick answer: CODE returns the numeric character code for the first character of a text string. For the basic Latin letter A, =CODE("A") is expected to return 65.
Availability and version history
- Introduced: documented by 2019-06-24 in the official WPS lesson; original introduction is not established.
- Availability: WPS Office for Windows Personal; numeric release not identified in the lesson. This is documentation evidence, not an installed-build guarantee.
- Scope: the exact supported build range is unverified. The cited Windows lesson does not establish equivalent availability in other WPS clients.
- Checked: October 14, 2026 against the function-specific lesson and vendor catalogue. Examples were independently calculated; no new native WPS test was performed.
Syntax and what is inspected
=CODE(text)
The argument is the text whose first character should be examined. A longer string still produces one code; CODE does not return an array of codes for every character.
The official Windows lesson establishes the first-character rule. The companion official CHAR lesson documents the basic letter-code ranges used in these examples. Extended and multilingual character mappings need platform-specific verification; do not treat CODE as a universal Unicode code-point function.
Example 1: show that only the first character matters
Enter A1:A5:
| Cell | Text |
|---|---|
| A1 | Text |
| A2 | Apple |
| A3 | Apricot |
| A4 | Banana |
| A5 | apple |
In B2 enter and fill down:
=CODE(A2)
Expected B2:B5: 65, 65, 66, 97.
Apple and Apricot produce the same result because both start with A. Lowercase apple starts with a different character and produces 97. This makes CODE useful for a focused character diagnostic, but unsuitable as a unique identifier or a checksum for a whole text string.
Example 2: inspect a later character with MID
Put AZa in D2. Use:
=CODE(MID(D2,1,1))
=CODE(MID(D2,2,1))
=CODE(MID(D2,3,1))
Expected results: 65, 90, 97.
MID extracts exactly one character at the requested position; CODE then examines that character. Supplying =CODE(D2) alone would return only 65.
For a review table, put positions 1, 2 and 3 in E2:E4 and use this in F2:
=CODE(MID($D$2,E2,1))
Fill down. The absolute reference keeps the source at D2 while the requested position changes with each row.
Example 3: verify a basic character round trip
=CHAR(CODE("Z"))
=CODE(CHAR(97))
Expected results: Z and 97. CHAR converts the basic code back to a character.
By contrast, =CHAR(CODE("Zone")) is expected to return Z, not Zone. The rest of the original string is never encoded by CODE, so the inverse operation cannot reconstruct it.
Advanced example: map a validated uppercase initial to an alphabet index
For a single uppercase ASCII letter from A through Z:
=CODE(A2)-64
With A, B, M and Z, expected results are 1, 2, 13 and 26. The subtraction works because the documented uppercase codes are consecutive from 65 to 90.
Apply this only after validating the input’s allowed character and length. Lowercase a would give 33, and a whole word beginning with A would give 1 despite containing more than one character. A numeric result is therefore not proof that the input was a valid single-letter code.
Use LEN to check the length and EXACT to compare against an approved value when appropriate. Keep validation separate if that makes the rules easier to inspect.
Blank-input guard and troubleshooting
Do not send a deliberately empty string to CODE when the intended task is to inspect a real character. For a text-source workflow, a simple guard is:
=IF(A2="","No character",CODE(A2))
For an empty A2, the intended output is No character; for Apple it is 65. A cell containing an ordinary space is not empty and should be reviewed as a character-bearing input.
The cited WPS lesson does not give an exhaustive error-code or encoding table. This guide therefore avoids promising a particular error label for every blank, invalid or non-Latin input. If two strings look alike but behave differently, inspect each position and retain the original text rather than immediately replacing characters based on a code guess.
When another check is better
Use EXACT for whole-string identity, LEN for length and MID for a chosen span. CODE answers the narrower question of a first character’s numeric code. It cannot confirm a complete word, validate an identifier’s business meaning or detect every visually confusable Unicode character across platforms.
References and verification
- Official WPS CODE lesson, published 2019-06-24 (Chinese; Windows Personal scope).
- WPS CODE documentation catalogue.
The lesson establishes the function-specific behavior discussed here. The catalogue confirms its listed identity, not an exact current build range. Expected outputs use original examples checked independently; native execution and broader client compatibility remain unverified.