I am an Access guy by nature .... so I have created the following procedures to help with my text cleaning tasks, they should work fine in Excel too ...
CODE
Public Function RemSpecial(strText As String, ParamArray strExeptions()) As String
'Removes special characters from a string. (Space is considered "Special")
'Usage:
'RemSpecial("My // text here") --> Yeilds: "Mytexthere"
'RemSpecial("My // text here", " ") --> Yeilds: "My text here"
'RemSpecial("My //\\ text here","\", " ") --> Yeilds: "My \\ text here"
Dim x As Integer
Dim Y As Integer
Dim strX As String
Dim strStrippedText As String
'Ascii codes
Const conNumberRangeStart = 48
Const conNumberRangeStop = 57
Const conCapLettersStart = 65
Const conCapLettersStop = 90
Const conSmallLettersStart = 97
Const conSmallLettersStop = 122
'Loop through each digit of the string to determine if it falls into the
'Ascii ranges OR is an exception
For x = 1 To Len(strText)
strX = Mid(strText, x, 1)
Select Case Asc(strX)
Case conNumberRangeStart To conNumberRangeStop, _
conCapLettersStart To conCapLettersStop, _
conSmallLettersStart To conSmallLettersStop
strStrippedText = strStrippedText & strX
Case Else
For Y = 0 To UBound(strExeptions())
If strX = strExeptions(Y) Then
strStrippedText = strStrippedText & strX
End If
Next Y
End Select
Next x
RemSpecial = strStrippedText
End Function
And this one ....
CODE
Public Function RemCode(strText, ParamArray intAsciiCodes()) As String
'Removes ascii codes from a string. Typical use is to remove 10 (carriage return) & 13 (line feed)
'Usage:
'RemCode("My text <cr><lf>is here",10,13) --> Yeilds: "My text is here"
'RemCode("My text is here", Asc("t")) --> Yeilds: "My ex is here"
Dim y As Integer
'Start with the string
strText = Nz(Trim(strText))
'Replace the Ascii Codes passed with a ZLS
For y = 0 To UBound(intAsciiCodes())
strText = Replace(strText, Chr(intAsciiCodes(y)), "")
Next y
'Return the result
RemCode = strText
End Function