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.

12 Responses to Remove Non-AlphaNumeric Characters from String

  1. Pingback: Importing WordPress Users via CSV Files | Webplus - web developer resource blog

  2. Pingback: debt consolidation companies

  3. Pingback: debt consolidation company

  4. Pingback: debt consolidation

  5. Pingback: home air purifier

  6. Pingback: wisdom teeth extraction

  7. Pingback: pechhulp europa

  8. Pingback: Austin Powers

  9. Pingback: debt collection agency

  10. Pingback: Wedding photographer services calgary

  11. Pingback: video x

  12. Pingback: Alternative Energy Projects

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>