Function to remove non-alphanumeric characters from an Excel spreadsheet
top of page

Function to remove non-alphanumeric characters from an Excel spreadsheet

The below function, posted here, will remove all non-alphanumeric characters from a cell:



Function RemoveNonAlpha(str As String) As String

Dim ch, bytes() As Byte: bytes = str

For Each ch In bytes

If Chr(ch) Like "[A-Z.a-z 0-9]" Then RemoveNonAlpha = RemoveNonAlpha & Chr(ch)

Next ch

End Function




Line breaks get removed too!

bottom of page