Skip to Main Content

Simpson Library Technical Services

Serves as a reference for all Staff.

Excel Macros

Remove Not Numbers from a range

Sub RemoveNotNum()
'Updateby20131129
Dim Rng As Range
Dim WorkRng As Range
On Error Resume Next
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
For Each Rng In WorkRng
    xOut = ""
    For I = 1 To Len(Rng.Value)
        xTemp = Mid(Rng.Value, I, 1)
        If xTemp Like "[0-9.]" Then
            xStr = xTemp
        Else
            xStr = ""
        End If
        xOut = xOut & xStr
    Next I
    Rng.Value = xOut
Next
End Sub