Skip to content

Instantly share code, notes, and snippets.

@brazilnut2000
Created July 11, 2013 05:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brazilnut2000/5972654 to your computer and use it in GitHub Desktop.
Save brazilnut2000/5972654 to your computer and use it in GitHub Desktop.
VBA: Remove list of characters from a string using Regex
Function RemoveInvalidCharacters(cleanMe As String) As String
Dim objRegex As Object
Set objRegex = CreateObject("vbscript.regexp")
With objRegex
.Global = True
.Pattern = "[\<\>\*\'\,\$\#\@\.\""\?\!\/\[\]\:\|\\\/\?|]"
RemoveInvalidCharacters = .Replace(cleanMe, "")
End With
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment