This post will guide you how to remove non numeric characters from cells with a formula in Excel. How do I remove non-numeric characters in cells in Excel. How to remove non-numeric characters from cells with VBA Code in Excel 2013/2016/2019/365. Or how to strip out non-numeric characters from a given cell in Excel.
Table of Contents
1. Removing Non Numeric Characters with a Formula
Assuming that you have a list of data in range B1:B5, and you want to remove all non-numeric characters from the range of cells B1:B5. How to achieve it. You can use an Excel Array formula based on the TEXTJOIN function, the IFERROR function, the ROW function and the INDIRECT function. Like this:
You need to Type this formula into a blank cell and then press CTRL +Shift + Enter keys to change the formula as an Array formula. and then drag the AutoFill Handle from C1 to C5.
2. Removing Non Numeric Characters with User Defined Function
You can also try to write an user defined function with VBA code to remove all non numeric characters from a cell in Excel. Just do the following steps:
#1 open your excel workbook and then click on “Visual Basic” command under DEVELOPER Tab, or just press “ALT+F11” shortcut.
#2 then the “Visual Basic Editor” window will appear.
#3 click “Insert” ->”Module” to create a new module.
#4 paste the below VBA code into the code window. Then clicking “Save” button.
Function RemoveAllNonNums(myCell As String) Dim myChar As String Dim x As Integer Dim i As String i = "" For x = 1 To Len(myCell) myChar = Mid(myCell, x, 1) If Asc(myChar) >= 48 And _ Asc(myChar) <= 57 Then i = i & myChar End If Next RemoveAllNonNums = Val(i) End Function
#5 back to the current worksheet, try to enter the below formula in Cell C1.
You can also use the following VBA macro to achieve the same result.
Sub RemoveAllNonNums() Dim myR As Range Dim myRange As Range Set myRange = Application.Selection Set myRange = Application.InputBox("select one range that you want to remove non-numeric characters", RemoveAllNonNums, myRange.Address, Type:=8) For Each myR In myRange myOut = "" For i = 1 To Len(myR.Value) tmp = Mid(myR.Value, i, 1) If tmp Like "[0-9]" Then myStr = tmp Else myStr = "" End If myOut = myOut & myStr Next i myR.Value = myOut Next End Sub
3. Removing Numeric characters only
If you only want to remove all numeric characters from a cell in Excel, and you can try to use the following array formula based on the TEXTJOIN function, the IF function, the ISERR function, the MID function, the ROW function and the INDIRECt function.
Type this formula in a blank cell and then press Ctrl + Shift + Enter shortcuts in your keyboard, and then drag the AutoFill Handle over other cells to apply this array formula.
4. Video: Removing Non Numeric Characters
This tutorial where we’ll explore techniques to clean and remove non-numeric characters from your data in Microsoft Excel. In this video, we’ll cover two efficient methods using formulas and a user-defined function.
5. SAMPLE FIlES
Below are sample files in Microsoft Excel that you can download for reference if you wish.
- Excel ROW function
The Excel ROW function returns the row number of a cell reference.The ROW function is a build-in function in Microsoft Excel and it is categorized as a Lookup and Reference Function.The syntax of the ROW function is as below:= ROW ([reference])….
- Excel IF function
The Excel IF function perform a logical test to return one value if the condition is TRUE and return another value if the condition is FALSE. The IF function is a build-in function in Microsoft Excel and it is categorized as a Logical Function.The syntax of the IF function is as below:= IF (condition, [true_value], [false_value])….
- Excel MID function
The Excel MID function returns a substring from a text string at the position that you specify.The syntax of the MID function is as below:= MID (text, start_num, num_chars)…
- Excel INDIRECT function
The Excel INDIRECT function returns the cell reference based on a text string, such as: type the text string “A2” in B1 cell, it just a text string, so you can use INDIRECT function to convert text string as cell reference….