Getting Rid of Everything Except Numbers (2024)

Getting Rid of Everything Except Numbers (1)Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. 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.

Getting Rid of Everything Except Numbers (2)

Written by Allen Wyatt (last updated August 5, 2023)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021

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. (If you are using Excel in Microsoft 365, you won't need to use 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.

If your version of Excel supports the LET, SEQUENCE, and TEXTJOIN functions (in other words, if you are using Excel in Microsoft 365 or Excel 2021), then you can use a different formulaic approach:

=LET(c, MID(A1,SEQUENCE(1,LEN(A1)),1), d, UNICODE(c),VALUE(TEXTJOIN("",TRUE,IF(d<48,"",IF(d>57,"",c)))))

This formula defines the variable c as a character in cell A1 and the variable d as the UNICODE value of that character. The actual formula then uses TEXTJOIN to put together a string of those characters that are numeric and, finally, VALUE converts that string to a value.

These formulaic approaches 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 NextEnd 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.

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, 2016, 2019, Excel in Microsoft 365, and 2021. You can find a version of this tip for the older menu interface of Excel 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. Learn more about Allen...

MORE FROM ALLEN

ScreenTip for an Image

You can configure images in Excel so that if someone clicks on them, a macro is executed. You cannot, however, have a...

Discover More

Correctly Repeated Words

There are times when you need to repeat a word in a document, but doing so triggers an "error reaction" from Word's...

Discover More

Using RD Fields with Chapter Headings

The RD field can be handy for pulling together a bunch of documents into a single file. However, using the field can play...

Discover More

Getting Rid of Everything Except Numbers (2024)
Top Articles
Fayette County KY Detention Center
Chickasaw County Regional Correctional Facility, MS Inmate Phone Service
Comenity Pay Ns Web Payment
895 Area Code Time Zone
Uber Hertz Marietta
Deshaun Watson Timeline: What Has Occurred Since First Lawsuit Filed
Mark Johnson Weather Salary
Editado Como Google Translate
Cristiano Ronaldo's Jersey Number: The Story Behind His No. 7 Shirt | Football News
Astral Ore Calamity
Terraria Melee Build Progression Guide & Best Class Loadouts
Is Robert Manse Leaving Hsn
The Dillards: From Mayberry's Darlings to Progressive Bluegrass Pioneers
Chicken Coop Brookhaven Ms
The latest on the Idaho student murders: Live Updates | CNN
Www.burlingtonfreepress.com Obituaries
12 Week Glute Program to Transform Your Booty with Free PDF - The Fitness Phantom
Weather Underground Shaver Lake
Dead By Daylight Subreddit
Kim Dotcom to fight extradition, says he won't get fair trial in US
Beetrose 'Planten un Blomen' - Rosa 'Planten un Blomen' ADR-Rose
Carlitos Caribbean Bar & Grill Photos
Suttermedicalfoundation.org/Urgent Care
Atdhe Net
Belly Button Torture Video
Jockey Standings Saratoga 2023
Jasper Jones County Trade
Case Overview: SAMA IM01 – SFF.Network
Restaurants Near Defy Trampoline Park
Brett Cooper Wikifeet
100000 Divided By 3
Circuit Court Evanston Wy
Hux Lipford Funeral
Februarycash2023
Recharging Iban Staff
Glassbox Eyecare
Brian Lizer Life Below Zero Next Generation
Wlox Jail Docket
Fallen Avatar Mythic Solo
Unraveling The Mystery Behind Campinos Leaked: A Deep Dive
JPX Studios/item asylum
My Compeat Workforce
Mission Impossible 7 Showtimes Near Regal Bridgeport Village
Molly Leach from Molly’s Artistry Demonstrates Amazing Rings in Acryli
Stihl Blowers For Sale Taunton Ma
Busted Bell County
Rabbi Raps
421 West 202Nd Street
Online-Shopping bei Temu: Solltest du lieber die Finger davon lassen?
Dungeon Family Strain Leafly
EXTON: THE MOST BEAUTIFUL CHOCOLATE BOX VILLAGE IN RUTLAND
Privateplaygro1
Latest Posts
Article information

Author: Tyson Zemlak

Last Updated:

Views: 5682

Rating: 4.2 / 5 (43 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Tyson Zemlak

Birthday: 1992-03-17

Address: Apt. 662 96191 Quigley Dam, Kubview, MA 42013

Phone: +441678032891

Job: Community-Services Orchestrator

Hobby: Coffee roasting, Calligraphy, Metalworking, Fashion, Vehicle restoration, Shopping, Photography

Introduction: My name is Tyson Zemlak, I am a excited, light, sparkling, super, open, fair, magnificent person who loves writing and wants to share my knowledge and understanding with you.