Quick reference for the Salesforce 15 → 18 digit ID conversion, since every formula version floating around Stack Overflow has the same bug.
Why 18 characters: the 15-char ID is case-sensitive. Excel and most SQL
databases aren't — so VLOOKUP silently merges records whose IDs differ only
in letter case. The 18-char form appends 3 check characters computed from
the case pattern, making the ID safe in case-insensitive systems.
The algorithm: split the ID into three 5-character chunks; per chunk,
set a bit for each uppercase letter (positions worth 1, 2, 4, 8, 16), then
map the 0–31 value onto A-Z0-5. Example: 00ABc → 12 → M.
The one rule that matters in Excel: use a CODE()-based formula
(testing character codes 65–90), never UPPER() comparisons — UPPER treats
digits as uppercase and produces a wrong suffix silently.
In Apex you rarely convert manually — Id variables normalize
automatically:
Id recordId = '0033000ABc0QyXb5'; System.debug(recordId); // 0033000ABc0QyXb5AMK Full walkthrough with the complete Excel formula, the to18CharId() Apex
utility, and a bulk converter with checksum verification:
Salesforce 15 to 18 Digit ID Conversion: Excel + Apex