Macro to Remove Non-Numeric Characters


Sub trimdata()
Dim Rng As Range
Dim WorkRng As Range
Dim rep As String
On Error Resume Next
xTitleId = "Excel Forum"
Set WorkRng = Application.Selection
'Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
For Each Rng In WorkRng
Rng.NumberFormat = ("#.###############################")
    xout = ""
    For i = 1 To Len(Rng.Text)
        xTemp = Mid(Rng.Text, i, 1)
        If xTemp Like "[-0-9.]" Then
            xStr = xTemp
        Else
            xStr = ""
        End If
        xout = xout & xStr
    Next i
    If xout = "" Then
        Rng.ClearContents
        Else
            If IsNumeric(xout) Then
                Rng = xout
                    Else
                Rng = ""
            End If
    End If
Next
Selection.NumberFormat = ("0.0############################")
End Sub

Let us know your interests

AnalystSolutions respects your privacy and will never share your information with others. You can remove yourself from any distribution with one click.

Subscriptions:
Assessment and Book Samples:
Workshop Free Previews:
captcha

You have Successfully Subscribed!

Let us know your interests

AnalystSolutions respects your privacy and will never share your information with others. You can remove yourself from any distribution with one click.

Subscriptions:
Assessment and Book Samples:
Workshop Free Previews:
captcha

You have Successfully Subscribed!

Evalulate our tools for free

We offer free full versions of our content for evaluation purposes (valued at over $700) to professionals holding the following roles: 

  • Manager of buy-side or sell-side analysts (DOR or PM)
  • CFA Society leader responsible for programming
  • Professor teaching students pursuing careers in equity research

You will receive:

  1. Free GAMMA PI™ assessment
  2. Free access to our presentation "Are You a Great Analyst?"
  3. Free full workshop (not "Preview" version), including all materials (Learner Workbook, Slides and Quick Reference Cards)
  4. Sample chapter of Best Practices for Equity Research Analysts

To ensure a quick verification of your role above (usually within one business day), please provide the email address issued by your organization.

captcha

You have Successfully Subscribed!

Try 2 of the 15 GAMMA PI™ Modules for Free

You will be directed to the FREE SAMPLE EDITION of our GAMMA PI™ Equity Research Analyst Self-Assessment.  Please provide a valid email address to receive  your results (your email address remains confidential within AnalystSolutions).

You have Successfully Subscribed!

Schedule a FREE Consultation

Please answer these questions to help James Valentine prepare for your call (he will keep your responses confidential)

You have Successfully Subscribed!

Take Our Free Quiz

You will be directed to our 20-question quiz to determine if you possess the skills of a seasoned equity research analyst.  Please provide a valid email address to receive  your results (your email address remains confidential within AnalystSolutions):

You have Successfully Subscribed!

Request Information

We will attempt to reply to you within one business day based upon the responses to our questions below.

captcha

You have Successfully Subscribed!