**Please Note: **
This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, and 2016. If you are using an earlier version (Excel 2003 or earlier), *this tip may not work for you*. For a version of this tip written specifically for earlier versions of Excel, click here: Getting Rid of Everything Except Numbers.

Linda has a column that contains alpha and numeric characters. She needs to retain the numeric characters and delete the alpha ones. For example, a cell may contain 10003E111 and she wants to end up with 10003111.

There are a few ways you can approach this problem. Before proceeding with any solution, however, you should make sure that you aren't trying to change something that isn't really broken. For instance, you'll want to make sure that the "E" that appears in the number isn't part of the format of the number—in other words, a designation of exponentiation. If it is, then you don't really want to remove the character because it will end up changing the nature of the underlying number.

If you determine that the characters aren't part of the number's format, then you can first try using a formula to remove the alpha characters. If the values you want to change are in column A, you could enter the following formula in column B:

=SUM(MID(0&A1,LARGE(INDEX(ISNUMBER(--MID(A1, ROW($1:$99),1))*ROW($1:$99),),ROW($1:$99))+1, 1)*10^ROW($1:$99)/10)

Make sure you enter this as an array formula by pressing **Ctrl+Shift+Enter**. The result is that column B contains the values from column A, without the alpha characters. You could use Paste Special to copy the information from column B to another column so that you end up with actual values instead of formula results.

This approach may work great for short-term use on a single workbook, but if you need to do this sort of data processing more often then you will want to create a user-defined function to do the processing. Here's an example:

Function OnlyNums(sWord As String) Dim sChar As String Dim x As Integer Dim sTemp As String sTemp = "" For x = 1 To Len(sWord) sChar = Mid(sWord, x, 1) If Asc(sChar) >= 48 And _ Asc(sChar) <= 57 Then sTemp = sTemp & sChar End If Next OnlyNums = Val(sTemp) End Function

You use this function by calling it from within a worksheet cell:

=OnlyNums(A1)

The function returns a numeric value. If you want to create an even shorter macro to do the processing, consider the following:

Function StripChar(aText As String) Dim I As Integer StripChar = "" For I = 1 To Len(aText) aChar = Mid(aText, I, 1) Select Case aChar Case "0" To "9" StripChar = StripChar & aChar End Select Next End Function

To use this function, use either of the following in your worksheet:

=STRIPCHAR(A1) =VALUE(STRIPCHAR(A1))

The first returns a text string consisting of the digits, the second returns the numeric version of that string.

*Note:*

If you would like to know how to use the macros described on this page (or on any other page on the *ExcelTips* sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

*ExcelTips* is your source for cost-effective Microsoft Excel training.
This tip (11750) applies to Microsoft Excel 2007, 2010, 2013, and 2016. You can find a version of this tip for the older menu interface of Excel here: **Getting Rid of Everything Except Numbers**.

**Save Time and Supercharge Excel!** Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out *Excel 2010 VBA and Macros* today!

Excel provides keyboard shortcuts for a variety of purposes. This tip examines two such shortcuts, designed to allow ...

Discover MoreWhen setting up a worksheet for others to use, you might want to make some limitations on what can be entered in certain ...

Discover MoreThe radical symbol is used frequently in some branches of mathematics. If you want to insert a radical symbol in a cell, ...

Discover More**FREE SERVICE:** Get tips like this every week in *ExcelTips,* a free productivity newsletter. Enter your address and click "Subscribe."

2019-09-17 11:47:31

Willy Vanhaelen

Function StripChar(aText As String) As Long

Dim I As Integer, aChar As String

For I = 1 To Len(aText)

aChar = Mid(aText, I, 1)

If IsNumeric(aChar) Then StripChar = StripChar & aChar

Next

End Function

It returns a numeric value.

Remove 'As Long' if you prefer a text string.

2017-05-13 06:13:38

Michael (Micky) Avidan

Although I met, during my Excel Career, longer formulas than the suggested above - here is a nice gimmick using the function: NPV (Net Present Value of an investment).

It is an Array Formula (Entered using <Ctrl+Shift+Enter>)

=NPV(-0.9,0,IFERROR(MID(A1,LEN(A1)-ROW(INDIRECT("A1:A"&LEN(A1)))+1,1)/100,""))

--------------------------

Michael (Micky) Avidan

“Microsoft® Answers" - Wiki author & Forums Moderator

“Microsoft®” Excel MVP – Excel (2009-2017)

ISRAEL

Got a version of Excel that uses the
ribbon interface (Excel 2007 or later)?
**This site is for you!** If you
use an earlier version of Excel, visit
our *ExcelTips* site focusing on the menu interface.

**FREE SERVICE:** Get tips like this every week in *ExcelTips,* a free productivity newsletter. Enter your address and click "Subscribe."

Copyright © 2020 Sharon Parq Associates, Inc.

## Comments