How to convert the phone number format to digits in Excel?
When working with Excel worksheets that contain lists of phone numbers, you may often encounter various formatting styles, such as parentheses, spaces, or dashes. These non-digit characters can interfere with data analysis, system imports, or automated dialing processes that require phone numbers to be in a pure digit sequence. If you need to standardize your data by extracting only the digits from any formatted phone number, this article provides several practical solutions to achieve this efficiently in Excel.
Here’s an example of the situation you might face—the left column contains phone numbers in different formats, while the right column shows the desired result: phone numbers with all non-digit characters removed, leaving only a continuous string of numerals.
Convert the phone number format to digits with formula
Use Flash Fill to extract digits from formatted phone numbers
Convert the phone number format to digits with Kutools for Excel
Use a macro to strip all non-digit characters from phone numbers
Convert the phone number format to digits with formula
Excel’s formulas allow you to remove unwanted characters and keep only digits in your phone number list. This method is especially useful if you prefer not to use add-ins or programming, and works well with phone numbers that follow a consistent format, such as (123)456-7890 or123-456-7890. However, if your data contains additional non-standard symbols or letters, more advanced techniques may be needed.
1. Select a blank cell (for example, C2) where you wish to display the extracted digits. Enter the following formula and press Enter:
=--SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2,"(",""),")","")," ",""),"-","")
Note: In this formula, A2 is the reference to the cell containing the original phone number. You can modify this reference if your data is in a different column or row.
2. While still selecting cell C2, drag the fill handle (the small square at the cell’s bottom-right corner) down to fill the formula for the rest of your list (for example, from C2 to C8). This will apply the formula to each phone number in the range.
Now, each phone number in your data range should be converted to a sequence of digits only.
Use Flash Fill to extract digits from formatted phone numbers
Excel’s Flash Fill feature offers a smart, manual alternative for extracting digits from phone numbers—especially effective when dealing with consistent list formats or when you want a fast, formula-free approach. Flash Fill evaluates patterns based on your manual entry, then fills in the rest of the column to match your example.
1. Assume your phone numbers are in column A, starting from cell A2. In the adjacent column (B2), manually type only the digits from your first phone number, omitting any symbols or spaces (for example: 1234567890).
2. Move to cell B3. Begin typing the digits from the next phone number. As you start, Excel will automatically detect the pattern and display a suggested autofill (highlighted in gray below the typed value).
3. Press Enter to accept the Flash Fill suggestion, and Excel will fill down the column with the extracted digits for all corresponding rows.
Tip: If Flash Fill does not trigger automatically, you can manually activate it by selecting the completed cell and using the shortcut Ctrl + E, or by clicking Data > Flash Fill from the Ribbon.
Precaution: Check the filled results for accuracy, particularly if the phone numbers have varying formats. Flash Fill may not work well on lists with unpredictable spacing, mixed formatting, or embedded text.
Summary suggestion: Flash Fill is a rapid method for one-time or small datasets, but it does not dynamically update if your original data changes. For constantly updating lists, consider formulas or VBA methods.
Convert the phone number format to digits with Kutools for Excel
For users looking for a more convenient, interactive solution, the Remove Characters utility in Kutools for Excel can efficiently remove specified symbols—including dashes, spaces, brackets, and more—from selected cells. This approach is ideal for those who frequently process structured data and want a quick, menu-driven method to clean up phone numbers without writing formulas or code.
1. Select the range containing the phone numbers you want to convert to digits, then navigate to Kutools > Text > Remove Characters.
2. In the Remove Characters dialog box, select the Custom option, and enter a hyphen – into the text box. You can also specify other characters you want to remove, such as spaces, parentheses, or periods, by adding them into the box. After setting, click OK to process the range.
The selected phone numbers will be updated instantly, with the specified characters removed, leaving a clean sequence of digits as shown below.
If you want to have a free trial (30-day) of this utility, please click to download it, and then go to apply the operation according above steps.
Use a macro to strip all non-digit characters from phone numbers
If your task involves numerous phone numbers in mixed or unpredictable formats (including special characters, spaces, extra punctuation, text, or even country codes), Excel’s VBA macros can provide a highly flexible and automatic way to clean these entries—all at once. This approach is especially useful for large datasets or repetitive cleaning tasks.
Applicable scenario: Use VBA if your phone number formats are irregular, you have many rows to process, or if neither formulas nor built-in features fully solve your needs. However, using macros requires saving your workbook in a macro-enabled format (*.xlsm) and granting macro permissions.
Steps:
1. Press Alt + F11 to open the Visual Basic for Applications editor. In the new window, click Insert > Module to create a blank module, then copy and paste the following VBA code into the code window:
Sub StripNonDigitsFromPhoneNumbers()
Dim xRg As Range
Dim xCell As Range
Dim xDigits As String
Dim i As Integer
Dim xTitleId As String
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set xRg = Application.Selection
Set xRg = Application.InputBox("Select the range with phone numbers", xTitleId, xRg.Address, Type:=8)
For Each xCell In xRg
xDigits = ""
For i = 1 To Len(xCell.Value)
If Mid(xCell.Value, i, 1) Like "#" Then
xDigits = xDigits & Mid(xCell.Value, i, 1)
End If
Next i
xCell.Value = xDigits
Next xCell
End Sub
2. And click the Run button (or press F5). In the dialog that appears, confirm or select your data range. The macro will automatically strip out all non-digit characters from each cell in your selection—leaving only the pure number sequence.
Parameter explanation: This macro processes each character in each cell, appending only numeric digits to the result. Adjust the selection to cover all desired columns/rows before running.
Tips & error reminders: Always save your workbook before running VBA scripts for the first time, as changes cannot be undone in one click. If you encounter a macro security warning, verify the code source and enable macros as needed. For collaborative environments, use caution so as not to overwrite critical data.
Summary suggestion: After running the macro, quickly scan the cleaned data to ensure accuracy. If country codes or extensions are needed, note that these will be concatenated into the digit string; handle such elements separately if required.
Related articles:
Best Office Productivity Tools
Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time. Click Here to Get The Feature You Need The Most...
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!