Solved

# Copying only the numbers from a cell

Posted on 2013-10-22
276 Views
I have a large column that has a combination of letters and numbers. They are not consistent , some has letters, and some has charterers like blank, (, or &.

Is there a way for me to copy to another column with just the numbers and have them stacked next to each other,

So for example, if the cell contains (#125-54A24) it will copy 1255424
So for example, if the cell contains -AA   23-   56267  it will copy 2356267
0
Question by:monster53
• 2
• 2

LVL 12

Expert Comment

ID: 39592774
Use array formula,

``````=SUM(MID(0&A1,LARGE(ISNUMBER(--MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))*ROW(INDIRECT("1:"&LEN(A1))),ROW(INDIRECT("1:"&LEN(A1))))+1,1)*10^ROW(INDIRECT("1:"&LEN(A1)))/10)
``````

After paste in the formula in edit mode, enter using Ctrl-Shift-Enter
0

Author Comment

ID: 39592843
I assume that i need to change the A1 to the appropriate cell.
I did that, however it is only returning the first digit in the cell, if the first digit is a number. If it is not, it is returning a 0.
0

LVL 45

Expert Comment

ID: 39592844
Put this UDF in a module and then use it as you would any formula. For example =(A2)

``````Function GetNumber(r As Range) As Long
Dim lngIndex As Long
Dim strTemp As String

For lngIndex = 1 To Len(r.Value)
If IsNumeric(Mid(r.Value, lngIndex, 1)) Then
strTemp = strTemp & Mid(r.Value, lngIndex, 1)
End If
Next

GetNumber = CLng(strTemp)
End Function
``````
0

LVL 12

Accepted Solution

Harry Lee earned 500 total points
ID: 39592886
monster53,

Please look at the attached sample file. It will show you how the cell references work on the formula.

Did you remember to enter using Ctrl-Shift-Enter?
Keep-Only-Numeric-Character.xlsx
0

Author Closing Comment

ID: 39597037
This is EXCELLENT !!!!!!!
0

## Join & Write a Comment Already a member? Login.

### Suggested Solutions

The new Microsoft OS looks great, is easier than ever to upgrade to, it is even free.  So what's the catch?  If you don't change the privacy settings, Microsoft will, in accordance with the (EULA) you clicked okay to without reading, collect all the…
No matter the version of Windows you are using, you may have some problems with Windows Search running too slow or possibly not running at all. Before jumping into how you can solve this issue, just know there are many other viable alternative deskt…
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

#### 747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

#### Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!