Friday, 6 November 2015

Replace accented characters with regular characters in Excel

In Visual Basic insert new module and paste the code below. Usage in the excel cell as =StripAccent(A1)

Function StripAccent(thestring As String)
Dim A As String * 1
Dim B As String * 1
Dim i As Integer
Const AccChars = "ŠŽšžYAÁÂAÄAÇEÉEËIÍÎI?NOÓÔOÖUÚUÜÝŐaáâaäaçeéeëiíîi?noóôoöuúuüýyőľřěňčČ"
Const RegChars = "SZszYAAAAAACEEEEIIIIDNOOOOOUUUUYOaaaaaaceeeeiiiidnooooouuuuyyolrencC"
For i = 1 To Len(AccChars)
A = Mid(AccChars, i, 1)
B = Mid(RegChars, i, 1)
thestring = Replace(thestring, A, B)
Next
StripAccent = thestring
End Function