Solved

Copying only the numbers from a cell

Posted on 2013-10-22
5
285 Views
Last Modified: 2013-10-24
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
Comment
Question by:monster53
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 12

Expert Comment

by:Harry Lee
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)

Open in new window


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

Author Comment

by:monster53
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 47

Expert Comment

by:Martin Liss
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

Open in new window

0
 
LVL 12

Accepted Solution

by:
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

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

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

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

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

Join & Ask a Question