VBA & Macro Problems

Convert Excel Digits to Letters with VBA or a Formula

Ayan MasoodAyan Masood Nov 20, 2026 868 views

Question details

Convert each digit in an Excel cell to its corresponding alphabetic letter, including values of varying lengths.

Convert Excel Digits to Corresponding Letters
Product
Microsoft Excel
Device & OS
not provided
Scenario
A user wants to convert digits individually, such as 4 to D, 7 to G, and 8 to H, and combine the letters in one cell.
Observed behavior
The desired result is a letter for each digit from 1 through 9, including in longer values such as 4598.
Before you start

Decide how to handle 0, which has no mapping in the examples. For values longer than 15 digits, enter the source values as text so Excel does not lose digits.

Solution 1Recommended

Create a VBA Function to Convert Each Digit to a Letter

Use this function in desktop Excel when you need to process values of different lengths and reject unsupported characters.

The function maps 1 through 9 to A through I. It returns #VALUE! for blank cells, 0, or other unsupported characters.

1
Open the VBA editor

In desktop Excel, open the Developer tab and select Visual Basic. If the Developer tab is hidden, enable it in Excel's ribbon settings.

2
Insert the function

In the VBA editor, select Insert > Module and paste this code: Public Function DigitLetters(ByVal value As Variant) As Variant Dim s As String, result As String, ch As String Dim i As Long If IsError(value) Then DigitLetters = CVErr(xlErrValue) Exit Function End If If IsEmpty(value) Then DigitLetters = CVErr(xlErrValue) Exit Function End If s = CStr(value) If Len(s) = 0 Then DigitLetters = CVErr(xlErrValue) Exit Function End If For i = 1 To Len(s) ch = Mid$(s, i, 1) If ch < "1" Or ch > "9" Then DigitLetters = CVErr(xlErrValue) Exit Function End If result = result & Chr$(Asc(ch) + 16) Next i DigitLetters = result End Function

3
Use the function

Return to the worksheet and enter =DigitLetters(A2) in an empty cell. For example, 478 returns DGH and 4598 returns DEIH.

4
Save and test

Select File > Save As and choose Excel Macro-Enabled Workbook (.xlsm). Test one-digit and longer inputs; if you see #VALUE!, check the source cell for 0, spaces, decimal points, or other unsupported characters.

Create a VBA Function to Convert Each Digit to a Letter
Macro permissions: Enable macros only for workbooks you trust. Excel for the web cannot run VBA macros.
Convert digits in WPS Spreadsheets

Convert Digits to Letters in WPS Spreadsheets

Use a nested SUBSTITUTE formula in WPS Spreadsheets to replace each digit from 1 through 9 with its corresponding letter, without writing a macro.

  1. 1. Open the spreadsheet: Open WPS Spreadsheets and select File > Open to load your workbook.
  2. 2. Select an output cell: Click an empty cell next to the first source value, such as B2 when the digits are in A2.
  3. 3. Enter the conversion formula: Enter =SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2,"1","A"),"2","B"),"3","C"),"4","D"),"5","E"),"6","F"),"7","G"),"8","H"),"9","I") and press Enter.
  4. 4. Apply and check: Drag the cell's fill handle down to convert additional rows. The formula leaves 0 and other nonmapped characters unchanged.
Convert values of different lengths with one formulaWork with Microsoft Excel XLSX and XLS filesFill the formula down a column to process multiple valuesUse a familiar spreadsheet interface
microsoft office alternative - wps office

Frequently Asked Questions

What does 4598 become?

It becomes DEIH: 4 maps to D, 5 to E, 9 to I, and 8 to H.

Why does the VBA function return #VALUE!?

The function accepts only digits 1 through 9. Check the referenced cell for 0, spaces, decimal points, letters, or an empty value.

Can I convert numbers with more than three digits?

Yes. Both methods process each digit separately. Enter values longer than 15 digits as text before conversion to prevent Excel from losing digits.

How is 0 handled?

The VBA function returns #VALUE! when it encounters 0. The SUBSTITUTE formula leaves 0 unchanged because no letter mapping for it is specified.

Why won't my custom function run in Excel for the web?

Excel for the web does not run VBA macros. Open the workbook in desktop Excel to use the function, or use the SUBSTITUTE formula instead.