Code:Enum WhatToRemove Text Numeric SpecialCharacters End Enum Function RemoveCharacters(ByVal StringToReplace As String, WhatRemove As WhatToRemove) As String Dim RegEx As Object Set RegEx = CreateObject("VBScript.RegExp") With RegEx .Global = True Select Case WhatRemove Case Text .Pattern = "[A-Za-z]" Case Numeric .Pattern = "\d" Case SpecialCharacters .Pattern = "[\;+\.+\#+\!+\'+\*+\,+\+\^+\&+\*+\@+\(+\)]" End Select End With RemoveCharacters= RegEx.Replace(StringToReplace, "") Set RegEx = Nothing End Function
Bookmarks