Remove non-numbers in Column F

Livin404

Well-known Member
Joined
Jan 7, 2019
Messages
743
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hello the following code I used in the past on another project. In this case I need to change it so it will start on Row 5 of Column F and the range will depend on the height of my table. I do not need a input box.

VBA Code:
Sub RemoveAllNonNums_Macro()
Dim myR As Range
Dim myRange As Range

Set myRange = Application.Selection
Set myRange = Application.InputBox("select one range that you want to remove non-numeric characters", RemoveAllNonNums, myRange.Address, Type:=8)
For Each myR In myRange
    myOut = ""
    For i = 1 To Len(myR.Value)
        tmp = Mid(myR.Value, i, 1)
        If tmp Like "[0-9]" Then
            myStr = tmp
        Else
            myStr = ""
        End If
        myOut = myOut & myStr
    Next i
    myR.Value = myOut
Next

End Sub
 
I was just offering him what I thought is an interesting (and more compact) alternative in case he might like to make use of it.
But it does a completely different job.
"125FGH9"
Original code returns 1259, your code returns nothing.
 
Upvote 0

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

Forum statistics

Threads
1,214,861
Messages
6,121,971
Members
449,059
Latest member
oculus

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top