Remove special characters from excel cell using macro

Press Alt+F11 then Insert>Module :

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Function removeSpecialCharacters(sInput As String) As String
Dim s As String, temp As String, i As Long
Dim C As String
s = sInput
If s = "" Then Exit Function
temp = ""
For i = 1 To Len(s)
C = Mid(s, i, 1)
If AscW(C) > 31 And AscW(C) < 127 Then
temp = temp & C
End If
Next i
removeSpecialCharacters = temp
End Function
Function removeSpecialCharacters(sInput As String) As String Dim s As String, temp As String, i As Long Dim C As String s = sInput If s = "" Then Exit Function temp = "" For i = 1 To Len(s) C = Mid(s, i, 1) If AscW(C) > 31 And AscW(C) < 127 Then temp = temp & C End If Next i removeSpecialCharacters = temp End Function
Function removeSpecialCharacters(sInput As String) As String

    Dim s As String, temp As String, i As Long
    Dim C As String

    s = sInput
    If s = "" Then Exit Function
    temp = ""

    For i = 1 To Len(s)
        C = Mid(s, i, 1)
        If AscW(C) > 31 And AscW(C) < 127 Then
            temp = temp & C
        End If
    Next i

    removeSpecialCharacters = temp
End Function