Link to home
Start Free TrialLog in
Avatar of New_Alex
New_AlexFlag for Cyprus

asked on

VBA, Remove Non AlphaNumeric Characters from A string

Hi people. Is it there any better way to write the below Function?


Function AlphaNumerize(anyString As String) As String

AlphaNumerize = Replace(anyString, "-", "")
AlphaNumerize = Replace(AlphaNumerize, "(", "")
AlphaNumerize = Replace(AlphaNumerize, ")", "")
AlphaNumerize = Replace(AlphaNumerize, "_", "")
AlphaNumerize = Replace(AlphaNumerize, "\", "")
AlphaNumerize = Replace(AlphaNumerize, "/", "")
AlphaNumerize = Replace(AlphaNumerize, "<", "")
AlphaNumerize = Replace(AlphaNumerize, ">", "")
AlphaNumerize = Replace(AlphaNumerize, "=", "")


End Function

Open in new window


Thanks
ASKER CERTIFIED SOLUTION
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of New_Alex

ASKER

Thank you SIR !
New_Alex,

Glad to help!  If you have not already done so, I would really appreciate it if you could please return to my article
https://www.experts-exchange.com/Programming/Languages/Visual_Basic/A_1336-Using-Regular-Expressions-in-Visual-Basic-for-Applications-and-Visual-Basic-6.html
and click 'Yes' for the 'Was this helpful?' voting.

Patrick