This is to remove excess characters from a string. It can be enhanced with options or changed depending if you want spaces or not etc.
Function fixchar(s As Variant) As Variant
Dim a, b, i As Integer
fixchar = ""
If Len(s) = 0 Then Exit Function
For i = 1 To Len(s)
b = Mid(s, i, 1)
' No Spaces: "[A-Z,a-z,0-9]"
' Spaces OK: "[A-Z,a-z,0-9 ]"
If b Like "[:,/,A-Z,a-z,0-9 ]" Then
fixchar = fixchar & b
End If
Next i
End Function
There is a more sophisticated function here where you can just run a macro on a selection instead of using a function as above.
Leave a Reply