Q:

How to change a cell depending on content in VBA

I have a lot of cells that contain some numbers and other non-relevant characters.  For example cell may look like: 65f or as 11,345asd. 
My goal is to delete everything but numbers in these cells, so I could use these numbers for further calculations.  I have found a lot of similar questions on different sites, but they are quite specific and I still don't understand how to do it properly. 
So the question is how to use change cells or maybe even a range of cells depending on contents?  I have some ideas how to do it using string function Replace.  But nothing that looks good. 
Thanks! 

A:

Another way using RegExp
Adding Reference
Add a reference to Microsoft VBScript Regular Expressions 5.5.  See image below

CODE: Paste this in a module
Option Explicit

Function GetNumbers(rng As Range) As Variant
    Dim StrSample As String
    Dim myRegExp As RegExp
    Dim myMatches As MatchCollection
    Dim myMatch As Match

    StrSample = rng. Value

    Set myRegExp = New RegExp

    With myRegExp
        .Pattern = "[^0-9]"
        .IgnoreCase = True
        .Global = True
    End With

    Set myMatches = myRegExp. Execute(StrSample)

    For Each myMatch In myMatches
      Debug. Print myMatch. Value
      StrSample = Replace(StrSample, myMatch. Value, "")
    Next
    GetNumbers = StrSample
End Function

SCREENSHOT:

EDIT
Here is a shorter version which doesn't use looping at all. 
Function GetNumbers(rng As Range) As Variant
    Dim myRegExp As RegExp
    Set myRegExp = New RegExp
    myRegExp. Pattern = "[^0-9]"
    myRegExp. Global = True
    GetNumbers = myRegExp. Replace(rng. Value, "")
End Function

A:

A wee function
public function TONUM(str As string) As string
dim i As long
for i = 1 To len(str)
    if not mid$(str, i, 1) Like "[0-9]" then mid$(str, i, 1) = "?" 
next
TONUM = replace$(str, "?", "") 
end function

