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

Getting Rid of Everything Except Numbers

by Allen Wyatt
(last updated January 5, 2015)


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 formulas to remove the alpha characters. If the values you want to change are in column A, you could enter the following (very long) formula in column B:


Make sure you enter this as an array formula by pressing Ctrl+Shift+Enter. Then enter the following into column C:


The result is that column C contains the values from column A, without the alpha characters. You could use Paste Special to copy the information from column C 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
    OnlyNums = Val(sTemp)
End Function

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


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
End Function

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


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

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (3840) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Getting Rid of Everything Except Numbers.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...


Keeping Full Menus Displayed

Word allows menus to be displayed in two modes. The default mode, which displays menu options dynamically, drives some people ...

Discover More

Size Limit for Documents

Word can handle large documents, but how large is large? This tip examines the issue and provides some advice on how ...

Discover More

Displaying Row and Column Labels

When you create a worksheet, it is common to place headings at the top of each column and the left of each row so you can ...

Discover More

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!

More ExcelTips (menu)

Reference Shortcut

Need to modify how a cell reference, in a formula, is constructed? The shortcut described in this tip will help you step ...

Discover More

Finding Unused Names

After months or years of naming things (such as cell ranges), you may find your workbook cluttered with a bunch of names that ...

Discover More

Converting Text to Values

When you import information originating in a different program, Excel may not do the best job at figuring out what various ...

Discover More

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

View most recent newsletter.


If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 9 - 2?

2016-03-11 06:54:32

Michael (Micky) Avidan

Try: =SUBSTITUTE(A1,"qwert",)
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2016)

2016-03-11 06:51:03

Michael (Micky) Avidan

In cell Q1 type:
=IF(LEFT(P1,3)="Inv",SUBSTITUTE(P1,LEFT(P1,FIND("||",SUBSTITUTE(P1," ","||",2))),),P1)
and copy down along to cell P300.
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2016)

2016-03-10 14:57:50


Great tip! How would I leave a specific character that is part of the number formatting. For example. I have numbers with a "." which I would like to keep

"000.000qwert0.000 qwert"

I'd like to remove the qwert and keep the "."

2015-05-19 14:17:15


In a data like this in column P, 300 lines:

Payment Type
Temp Living (10/24/14 - 12/24/14) Cable
Temp Living (10/24/14 - 12/24/14) Utilities
Inv I-333-9677 3 Day Bundle Home Finding
Inv 999994 Temp Living (09/09/99 - 09/89/99) Lodging (89 Days)
Temp Living (01/13/15 - 02/21/15) Car Rental (49 Days)
Inv 90098076 Household Sea Shipment
Inv 90098076 Household Sea Valuation
Inv 99490000487439 Temp Living (08/09/99 - 08/88/99) Lodging (84 Days)
Inv I-333-4899 8 Day Bundled Service
Inv 999676 Temp Living (09/09/99 - 09/39/99) Lodging (39 Days)
Inv 9987 Immigration (Charoensukmongkol) Visa App
Inv 9987 Immigration (Dependent)
Househumting Trip (03/23/15 - 03/27/15) Meals
Househunting Trip (03/23/15 - 03/26/15) (5 Days)
Househunting Trip (03/23/15 - 03/27/15) Car Rental (4 Days)
Househunting Trip (03/23/15) Telephone/Sim Card
Househunting Trip (03/27/15) Rental Car Gas
Visa / Immigration (03/12/15) Fam
Visa Blanket-L Fraud (03/12/15) EE
Visa Fee (02/26/15)
Inv 90009803 Household Sea Shipment
Inv 90009803 Household Sea Valuation
Inv 999674 Temp Living (09/09/99 - 09/07/99) Lodging (97 Days)
School Tuition Deposit 2015-2016 Cedrick
School Tuition Deposit 2015-2016 Margaret
School Deposit (03/04/15) Matriculation Thais
School Deposit (02/09/15) Tuition Oscar
Inv 90006686 Household (Jan-March 8099) Perm Storage
Inv 90006686 Household (Nov-Dec 8094) Perm Storage
Inv 90006686 Household (Jan-March 8099) Perm Valuation
Inv 90006686 Household (Nov-Dec 8094) Perm Valuation
Inv 90006686 Household into Perm Storage
within one column I need to remove the Invoce number, basically to replace "Inv xxxxxxxx" by nothing and each invoice number is different. Can't remove the date tho so replacing numbers by ""is not a good tip. Any help on this?

2015-01-06 13:30:15

Willy Vanhaelen

I always prefer simple UDF's instead of complicated long formulas. Here is a very simple UDF for the job:

Function StripChar(S As String)
Dim X As Integer, C As String
For X = 1 To Len(S)
C = Mid(S, X, 1)
If IsNumeric(C) Then StripChar = StripChar & C
End Function

2015-01-06 10:09:56

Michael (Micky) Avidan

I believe the following "short" Array-Formula will accomplish the task:
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2015)

2015-01-05 08:58:44

Magnus Eriksen

Hi Brian Schroeder,

You might already have solved your issue, didn't see the comment until now.

Would it would be a possibility for you to multiply the cell value with 1 (AD1*1)? If the cell contains an alpha character, this would render "0".

2014-05-22 13:02:12

Brian Schroeder

Hi, I have two columns (AD and AE) which contain either numbers OR alpha characters. I want to run a macro to replace any alpha characters with 0. I've tried many solutions to similar (but not exact) issues, but cannot get the desired results. Any help would be greatly appreciated!

This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.

Newest Tips

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

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.