
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Remove Non-Numeric Characters from Cells in Excel
Although Excel is a strong tool for data organisation and analysis, the data we work with occasionally can be disorganised and contain extra characters that impede our calculations and analyses. Fortunately, Excel has a number of methods for efficiently cleaning up data; in this article, we'll concentrate on deleting non-numeric characters from cells.
Let's first examine the importance of deleting non-numeric characters before going on to the techniques. There may be instances when working with mixed data types datasets (numbers, text, symbols, etc.) where you just require the numerical values. For instance, you might wish to remove any non-numeric components from the cells while working with financial data, sales figures, or any other numerical calculations in order to provide correct results.
Remove Non Numeric Characters From Cells
Here, we will first create a VBA module and then run it to complete the task. So let us see a simple process to learn how you can remove non-numeric characters from cells in Excel.
Step 1
Consider an Excel sheet where the data in the sheet is similar to the below image.
First, right-click on the sheet name and select View code to open the VBA application.
Right-click > View Code.
Step 2
Then click on Insert and select Module, then copy the below code into the text box.
Insert > Module > Copy.
Code
Sub RemoveNotNum() Dim Rng As Range Dim WorkRng As Range On Error Resume Next xTitleId = "Remove Non Numeric" 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
Step 3
Then click F5 to run the module. Then select the range of cells and click OK to complete the task. Then you will see that non-numeric characters will be removed.
F5 > Select Cells > OK
This is how you can remove non-numeric characters in Excel.
Note
If the number contains decimals, use the below VBA code.
Code
Sub RemoveNotNum() Dim Rng As Range Dim WorkRng As Range On Error Resume Next xTitleId = "Remove Non Numeric" 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
Conclusion
In this tutorial, we have used a simple example to demonstrate how you can remove non-numeric characters from cells in Excel to highlight a particular set of data.