Last active
April 22, 2024 16:40
-
-
Save mpecka/dba4344af56fb34744bc60cbfe0e66ef to your computer and use it in GitHub Desktop.
Excel Remove Accents
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Function StripAccent(thestring As String) | |
| Dim A As String * 1 | |
| Dim B As String * 1 | |
| Dim i As Integer | |
| Const AccChars= "áäčďéěíĺľňóôőöŕšťúůűüýřžÁÄČĎÉĚÍĹĽŇÓÔŐÖŔŠŤÚŮŰÜÝŘŽ" | |
| Const RegChars= "aacdeeillnoooorstuuuuyrzAACDEEILLNOOOORSTUUUUYRZ" | |
| 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 |
Hi
I have a weird behavior, the script returns something, namely the same accented text as before. The characters to be replaced are all in the AccChars/RegChars strings. Any idea what is causing this behavior?
Chris
Actually what I wrote was wrong. The characters are not in the string, they just look similar. When I try to insert the characters I want replaced, Excel puts a questionmark instead of the character. Does this mean the code page I am using for the macro does not support these characters? I can display them on the Excel sheet.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can add the new accent character to the string AccChars, then add the corresponding 'regular' (non-accented) character to RegChars, in the same position.