You can remove all letters from a cell’s text (while leaving numbers, punctuation, spaces, etc.) by using an array formula that “checks” each character. There are several approaches to do this. Below are two common methods:
Method 1: Using a Dynamic Array Formula (Excel 365 and later)
If you have Excel 365 (or any version supporting dynamic arrays), you can use the following formula. Suppose your text is in cell A1; enter this formula in another cell:
=TEXTJOIN("", TRUE, IF(
ISNUMBER(SEARCH(MID(A1, SEQUENCE(LEN(A1)), 1), "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")),
"",
MID(A1, SEQUENCE(LEN(A1)), 1)
))
How it works:
-
SEQUENCE(LEN(A1)):
This generates an array of numbers from 1 to the number of characters in A1.
-
MID(A1, SEQUENCE(LEN(A1)), 1):
This extracts each character from A1.
-
SEARCH(..., "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"):
Checks if the extracted character is in the list of upper and lower case letters.
- If it finds a letter,
SEARCH returns a number.
- If not, it returns an error.
-
ISNUMBER(...):
Converts this to TRUE (if a letter) or FALSE (if not a letter).
-
IF(..., "", MID(...)):
If the character is a letter (TRUE), it returns an empty string; otherwise, it returns the character.
-
TEXTJOIN("", TRUE, ...):
Joins the resulting characters back together into one string, ignoring empty strings.
The result is the contents of A1 but with all letters removed.
Method 2: Using an Array Formula Compatible with Older Versions of Excel
For older versions of Excel (pre-dynamic arrays), you can use a similar formula, but you must commit it as an array formula. Suppose your text is in cell A1; enter this formula:
=TEXTJOIN("", TRUE, IF(
ISERROR(SEARCH(MID(A1, ROW(INDIRECT("1:" & LEN(A1))), 1), "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")),
MID(A1, ROW(INDIRECT("1:" & LEN(A1))), 1),
""
))
Important:
After typing or pasting the formula, press Ctrl+Shift+Enter (instead of just Enter). This tells Excel that it is an array formula.
Explanation:
-
ROW(INDIRECT("1:" & LEN(A1))):
Generates an array from 1 to the length of the string in A1.
-
The rest of the formula works in a similar way to Method 1, processing one character at a time and reassembling the string without letters.
Alternative: Using a VBA User Defined Function (UDF)
If you frequently need to perform this task, you might find it convenient to use VBA:
-
Press Alt+F11 to open the VBA editor.
-
Go to Insert > Module.
-
Paste the following code:
Function RemoveLetters(str As String) As String
Dim i As Integer
Dim result As String
result = ""
For i = 1 To Len(str)
Dim ch As String
ch = Mid(str, i, 1)
' Check if the character is NOT a letter
If Not (ch Like "[A-Za-z]") Then
result = result & ch
End If
Next i
RemoveLetters = result
End Function
-
Close the VBA editor.
-
In Excel, use the function like any other: if cell A1 contains your text, enter the following in another cell:
=RemoveLetters(A1)
This UDF checks each character and concatenates it only if it is not a letter.
Any of these methods will remove all letters from your data while preserving numbers, symbols, and spaces. Choose the one which best fits your version of Excel and your comfort level with formulas or VBA.