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. ...


Working with Table Columns and Rows

Need to add or delete columns and rows from a table? It's easy to do using the tools provided in Word.

Discover More

Changing Section Headers

Add subtotals to a worksheet and you can instruct Excel to start each new subtotal section on a new printed page. You may ...

Discover More

Ignoring Punctuation in Names

If you have a word that includes punctuation as part of the word itself, then you may be frustrated by how Word treats that ...

Discover More

Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!

More ExcelTips (menu)

Correcting a Capital Mistake

As you are entering data in a worksheet, Excel can monitor what you type and make corrections for common mistakes. One such ...

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

Inserting a Row or Column

When editing worksheets, it is important to know how to add rows and columns. Excel provides a couple of quick ways you can ...

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 6 - 0?

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.