@snb and ExcelFox...
And I couldn't help developting a non-RegExp function...
Note: I used snb's special characters list as it seemed more complete to me, although I also chose to remove the backslash character as well (you both allowed it to remain when special characters were to be removed).Code:Enum WhatToRemove Text = 0 numeric = 1 SpecialCharacters = 2 End Enum Function RemoveCharacters(ByVal StringToReplace As String, WhatRemove As WhatToRemove) As String Dim X As Long, Pattern() As String Pattern = Split("[A-Za-z] # [#~!@$%^&*()'={}[:""+;<>?,./\-]") If WhatRemove = SpecialCharacters Then StringToReplace = Replace(StringToReplace, "]", "") For X = 1 To Len(StringToReplace) If Mid(StringToReplace, X, 1) Like Pattern(WhatRemove) Then Mid(StringToReplace, X, 1) = Chr(1) Next RemoveCharacters = Replace(StringToReplace, Chr(1), "") End Function




Reply With Quote
Bookmarks