Loading

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.

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.

Learn more about Allen...

ExcelTips FAQ

ExcelTips Resources

Ask an Excel Question

Make a Comment

Free Business Forms

Free Calendars

** 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),

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:

=MID(A1,MATCH(TRUE,ISERROR(1*MID(A1,ROW(INDIRECT ("1:"&LEN(A1))),1)),0),-MATCH(TRUE,ISERROR(1*MID (A1,ABS(ROW(INDIRECT("1:"&LEN(A1)))-LEN(A1)-1),1)) ,0)+LEN(A1)+2-MATCH(TRUE,ISERROR(1*MID(A1,ROW (INDIRECT("1:"&LEN(A1))),1)),0))

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

=SUBSTITUTE(A1,B1,"")

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

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

*Related Tips:*

**Comprehensive VBA Guide** Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out *Mastering VBA for Office 2010* today!

@Wes,

Try: =SUBSTITUTE(A1,"qwert",)

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

Michael (Micky) Avidan

“Microsoft® Answers" - Wiki author & Forums Moderator

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

ISRAEL

Try: =SUBSTITUTE(A1,"qwert",)

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

Michael (Micky) Avidan

“Microsoft® Answers" - Wiki author & Forums Moderator

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

ISRAEL

@Yuki,

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)

ISRAEL

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)

ISRAEL

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

"000.000qwert0.000 qwert"

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

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?

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?

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

Next

End Function

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

Next

End Function

I believe the following "short" Array-Formula will accomplish the task:

=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)

Michael (Micky) Avidan

“Microsoft® Answers" - Wiki author & Forums Moderator

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

ISRAEL

=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)

Michael (Micky) Avidan

“Microsoft® Answers" - Wiki author & Forums Moderator

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

ISRAEL

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

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

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!