Remove Non-AlphaNumeric Characters from String

The function below will allow us to remove a non alphanumeric character from an input string.

Be careful though, lengther the string, more time needed to evaluate each string on the sentence.

To bad that I don’t have any idea on how to use Regular Expression in Excel VBA, if we can use regex to replace all the unwanted character directly, it would be great :)

Function GETALPHANUMERIC(text)

str_all = "abcdefghijklmnopqrstuvwxyz1234567890"
For lenstr = 1 To Len(text)
    If InStr(str_all, LCase(Mid(text, lenstr, 1))) Then
        GETALPHANUMERIC = GETALPHANUMERIC & Mid(text, lenstr, 1)
    End If
Next

End Function

If somehow what we need is only the apha part without the numeric part or vice versa, simply adjusting the value of str_all variable will solve it.

This entry was posted in Excel Formula, Excel VBA Function and tagged , . Bookmark the permalink.

911 Responses to Remove Non-AlphaNumeric Characters from String

  1. Pingback: company web site

  2. Pingback: norcross tree removal

  3. Pingback: body repair

  4. Pingback: purchase payday loan online

  5. Pingback: mansfield montessori academy

  6. Pingback: diabetic bags

  7. Pingback: view site

  8. Pingback: www.easyloanfast.com

  9. Pingback: business coaches brisbane

  10. Pingback: california workers comp insurance rates

  11. Pingback: cordless impact wrench reviews

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>