Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to remove non numeric characters from cells in Excel?

Supposing you have a worksheet with lots of such data ABCD4578124YUIOH, and you only want to remove the non-numeric characters  ABCDYUIOH but keep the numeric characters in cells. Of course, you can remove those characters one by one, but right here you can get rid of the non-numeric characters from cells quickly as follows:

Remove non-numeric characters with VBA code

A handy tool to remove non-numeric characters with one click


Remove numeric, alphabetic,non-numeric, non-printable or alphanumeric characters from text strings:

With Kutools for Excel's Remove Characters utility, you can quickly remove numreic, non-numeric, alphabetic or non-alphabetic characters and so on from a list of text strings as you need.

doc remove non numeric characters 6

Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days. Download and free trial Now!


Remove non-numeric characters with VBA code

To remove non-numeric characters from a range with VBA code, please do as follow:

1. Click Developer > Visual Basic to open the Microsoft Visual Basic for applications window. In the Microsoft Visual Basic for applications window, click Insert > Module, and then copy and paste the following codes into the module:

VBA: Remove all non-numeric characters

Sub RemoveNotNum()
'Updateby20131129
Dim Rng As Range
Dim WorkRng As Range
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
For Each Rng In WorkRng
    xOut = ""
    For i = 1 To Len(Rng.Value)
        xTemp = Mid(Rng.Value, i, 1)
        If xTemp Like "[0-9]" Then
            xStr = xTemp
        Else
            xStr = ""
        End If
        xOut = xOut & xStr
    Next i
    Rng.Value = xOut
Next
End Sub

2. Then click the button to run the code, In the popping up KutoolsforExcel dialog box, select a range with the non-numeric characters you want to remove, and then click the OK button. See screenshot:

doc remove non numeric characters 1 copy

3. Then all non-numeric characters in selected range are removed.

doc remove non numeric characters 2

If the numbers with decimal points, you can use the following VBA:

Sub RemoveNotNum()
'Updateby20131129
Dim Rng As Range
Dim WorkRng As Range
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
For Each Rng In WorkRng
    xOut = ""
    For i = 1 To Len(Rng.Value)
        xTemp = Mid(Rng.Value, i, 1)
        If xTemp Like "[0-9.]" Then
            xStr = xTemp
        Else
            xStr = ""
        End If
        xOut = xOut & xStr
    Next i
    Rng.Value = xOut
Next
End Sub

You can see the results as below screenshot shown:

doc remove non numeric characters 3


A handy tool to remove non-numeric characters with one click

For removing non-numeric characters in a range, Kutools for Excel’s Remove Characters utility can get it done with one click.

Kutools for Excel : with more than 300 handy Excel add-ins, free to try with no limitation in 60 days. 

After installing Kutools for Excel, please do as below:

1. Highlight the range you want to remove non-numeric characters. Click Kutools > Text > Remove Characters.

doc remove non numeric characters 4

2. In the Remove Characters dialog box, check the Non-numeric option in the Remove Characters section, and then click the OK or Apply button. And the non-numeric characters are removed from the selection immediately. See screenshot:

doc remove non numeric characters 5

Click to Download Kutools for Excel and free trial Now!

For more detailed information about Remove Characters of Kutools for Excel, please visit Remove characters features description.


Demo: Remove numeric, alphabetic, non-printable or alphanumeric characters from cells

Kutools for Excel: with more than 200 handy Excel add-ins, free to try with no limitation in 60 days. Download and free trial Now!


Related articles:


Excel Productivity Tools

Ribbon of Excel (with Kutools for Excel installed)

300+ Advanced Features Increase Your Productivity by 70%, and Help You To Stand Out From Crowd!

Would you like to complete your daily work quickly and perfectly? Kutools For Excel brings 300+ cool and powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) for 1500+ work scenarios, helps you solve 80% Excel problems.

  •  Deal with all complicated tasks in seconds, help to enhance your work ability, get success from the fierce competition, and never worry about being fired.
  •  Save a lot of work time, leave much time for you to love and care the family and enjoy a comfortable life now.
  •  Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands, and give you a healthy body.
  •  Become an Excel expert in 3 minutes, and get admiring glance from your colleagues or friends.
  •  No longer need to remember any painful formulas and VBA codes, have a relaxing and pleasant mind, give you a thrill you've never had before.
  •  Spend only $39, but worth than $4000 training of others. Being used by 110,000 elites and 300+ well-known companies.
  •  60-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years. Buy once, use forever.
  •  Change the way you work now, and give you a better life immediately!

Office Tab Brings Efficient And Handy Tabs to Office (include Excel), Just Like Chrome, Firefox, And New IE

  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Open and create documents in new tabs of same window, rather than in new windows.
  • Help you work faster and easily stand out from the crowd! One second to switch between dozens of open documents!
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Abi DC · 1 years ago
    HI Thanks for the coding, i am getting the syntax error highlighted on For i = 1 To Len(Rng.Value) and the debug Sub RemoveNotNum() is highlighted in yellow.. kindly advice.
  • To post as a guest, your comment is unpublished.
    usuc · 1 years ago
    The VBA works great. I modified it to always work on a column, as shown:

    For Each Cell In Range("B2:B" & ActiveSheet.UsedRange.Rows.Count)

    xOut = ""

    For i = 1 To Len(Cell.Value)

    xTemp = Mid(Cell.Value, i, 1)

    If xTemp Like "[0-9]" Then

    xStr = xTemp

    Else

    xStr = ""

    End If

    xOut = xOut & xStr

    Next i

    Cell.Value = xOut

    Next

    I also used this to sort a column by the last digit, changing the last part to Cell.Value = Right(xOut, 1) then sorting it numerically.
  • To post as a guest, your comment is unpublished.
    Naresh kumar · 2 years ago
    Send me it on my email id
    • To post as a guest, your comment is unpublished.
      samola · 2 years ago
      Hi,

      I want to use this macro but want to pre-define a range. Can you please let me know how to pre-define the range.

      Thanks,
      Samit
  • To post as a guest, your comment is unpublished.
    Cole · 3 years ago
    Just wanted to let you know that if the string starts with zero(s), or starts with letters, followed by zero(s), followed by the rest of the string this will remove all of the beginning zeroes. This is weird because it doesn't remove the zero(s) if they are between other non-zero numbers within the string, only if they start the string or are the first numbers after the initial letters in a string.

    Example.

    0060100 would come out as 60100

    PFF057726 would come out as 57726.

    Let me know if you have an explanation for this and can think of a solution. Thank you.
  • To post as a guest, your comment is unpublished.
    Roger · 4 years ago
    Thanx Guys for such a nice work. The script is awesome and it worked for. Keep it up guys.