In VBA, convert a number from 1 to 26 to a letter with Chr(64 + n): Chr(65) is "A" and Chr(90) is "Z." For Excel column letters, use Split(Cells(1, n).Address, "$")(1), which turns 28 into "AB" and 16,384 into "XFD."
Type numbers into the tool, pick A1Z26 or column letters, and it writes a ready-to-paste VBA module with a NumToLetter function and a Demo sub. The editor preview shows the function in Module1 and the Immediate window prints the result of each call.
How number to letter VBA calculator works?
To convert a number to a letter in VBA, the number to letter VBA calculator adds 64 to the number and reads the character with that code. The calculator splits your list of numbers, checks each one, converts 1–26 with Chr(64 + n), or builds column letters (27 = AA) in column mode, and writes runnable VBA code for the same numbers. 8 5 12 12 15 becomes HELLO.
- Read the numbers
Spaces, commas, or new lines separate the numbers.
8 5 12 12 15 - Pick the mode
A1Z26 maps 1–26 to A–Z. Column mode maps any positive number to Excel column letters.
A1Z26 - Run Chr(64 + n)
Each number n becomes the character with code 64 + n (A = 65 in ASCII and Unicode).
Chr(64 + 8) = "H" - Write the code
The VBA snippet and its output appear side by side. Tick lowercase to use code 96 + n.
HELLO
Column mode uses the worksheet: Split(Cells(1, n).Address, "$")(1) returns the column letters for any n up to 16,384 in Excel 2007 and later.
Number to letter VBA formula
The number to letter VBA formula is a code point offset. letter = character(64 + n) for capitals and character(96 + n) for lowercase, for n from 1 to 26. Column letters use bijective base 26: take (n − 1) mod 26, then divide (n − 1) by 26, and repeat.
Formula
Where
- n
- number from 1 to 26 (A1Z26) or any positive whole number (columns)
- 64
- ASCII code of @, the character before A (65)
- 96
- ASCII code of `, the character before a (97)
- r
- remainder 0–25, read as A–Z
Worked example
Number to letter VBA conversion chart
The number to letter VBA conversion chart lists all 26 A1Z26 numbers with the ASCII codes and the VBA expression. 1 = A (code 65), 13 = M (code 77), and 26 = Z (code 90).
| n | Letter | Code (capital) | Code (lowercase) | VBA expression |
|---|---|---|---|---|
| 1 | A | 65 | 97 | Chr(65) = "A" |
| 2 | B | 66 | 98 | Chr(66) = "B" |
| 3 | C | 67 | 99 | Chr(67) = "C" |
| 4 | D | 68 | 100 | Chr(68) = "D" |
| 5 | E | 69 | 101 | Chr(69) = "E" |
| 6 | F | 70 | 102 | Chr(70) = "F" |
| 7 | G | 71 | 103 | Chr(71) = "G" |
| 8 | H | 72 | 104 | Chr(72) = "H" |
| 9 | I | 73 | 105 | Chr(73) = "I" |
| 10 | J | 74 | 106 | Chr(74) = "J" |
| 11 | K | 75 | 107 | Chr(75) = "K" |
| 12 | L | 76 | 108 | Chr(76) = "L" |
| 13 | M | 77 | 109 | Chr(77) = "M" |
| 14 | N | 78 | 110 | Chr(78) = "N" |
| 15 | O | 79 | 111 | Chr(79) = "O" |
| 16 | P | 80 | 112 | Chr(80) = "P" |
| 17 | Q | 81 | 113 | Chr(81) = "Q" |
| 18 | R | 82 | 114 | Chr(82) = "R" |
| 19 | S | 83 | 115 | Chr(83) = "S" |
| 20 | T | 84 | 116 | Chr(84) = "T" |
| 21 | U | 85 | 117 | Chr(85) = "U" |
| 22 | V | 86 | 118 | Chr(86) = "V" |
| 23 | W | 87 | 119 | Chr(87) = "W" |
| 24 | X | 88 | 120 | Chr(88) = "X" |
| 25 | Y | 89 | 121 | Chr(89) = "Y" |
| 26 | Z | 90 | 122 | Chr(90) = "Z" |
Column numbers past 26
| n | Column letters |
|---|---|
| 27 | AA |
| 28 | AB |
| 52 | AZ |
| 53 | BA |
| 78 | BZ |
| 702 | ZZ |
| 703 | AAA |
| 1,000 | ALL |
| 16,384 | XFD |
VBA number to letter functions
' A1Z26: 1 = A ... 26 = Z
Function NumToLetter(n As Long) As String
If n >= 1 And n <= 26 Then NumToLetter = Chr(64 + n)
End Function
' Excel column letter: 1 = A, 27 = AA, 16384 = XFD
Function ColLetter(n As Long) As String
ColLetter = Split(Cells(1, n).Address, "$")(1)
End Function
' Column letter without touching the worksheet (works in Word and Access too)
Function ColLetter2(ByVal n As Long) As String
Dim r As Long
Do While n > 0
r = (n - 1) Mod 26
ColLetter2 = Chr(65 + r) & ColLetter2
n = (n - 1) \ 26
Loop
End Function
Cells(1, n).Address returns "$AB$1"; splitting on "$" gives 3 parts, and part (1) is the letters. ColLetter2 uses the bijective base-26 loop instead, so it runs in any Office app.
How to add the function to Excel
- Press Alt + F11 to open the Visual Basic Editor.
- Click Insert › Module.
- Paste the code from the tool.
- Back in the sheet, type
=NumToLetter(A1)in any cell. - Save the file as .xlsm (macro-enabled), or the code is removed on save.
Letter to number in VBA
Use Asc(UCase(letter)) - 64 for a single letter and Range(col & "1").Column for column letters. Asc("C") - 64 returns 3, and Range("AB1").Column returns 28.
Frequently asked questions
How do I convert a number to a letter in VBA?
Use Chr(64 + n). Chr(64 + 1) returns "A" and Chr(64 + 26) returns "Z." Use Chr(96 + n) for lowercase.
How do I get a column letter from a column number in VBA?
Use Split(Cells(1, n).Address, "$")(1). For n = 28, it returns "AB."
Why does Chr(64 + 27) not return AA?
Chr returns 1 character. Character 91 is "[", so numbers above 26 need the column letter function, not Chr.
How do I convert a letter to a number in VBA?
Use Asc(UCase(x)) - 64 for 1 letter, or Range(x & "1").Column for column letters.
What is the VBA formula for number to letter?
The VBA formula is Chr(64 + n), so Chr(64 + 3) returns "C". Use Chr(96 + n) for lowercase.
What does Chr(65) return in VBA?
Chr(65) returns "A". Chr(90) returns "Z" and Chr(97) returns "a".
What is the largest column number in VBA?
16,384, which is column XFD in Excel 2007 and later. Excel 2003 stopped at column 256 (IV).
More number and letter tools