In excel, I need to process data that is prepared and exported from another application in the .xls file format.
Because certain language-specific characters in this .xls file are not displayed properly (eg
"è" instead of
"č"), I wanted to replace them with the help of a macro. So I recorded a macro, which should replace, for example, all
"è" characters with the
"č" character. There was no problem while recording the macro and all the characters were replaced correctly. But running the same macro on another .xls file caused a problem because instead of all
"è" characters, all
"e" characters were replaced with
"č" character.
This is part of a code I recorded:
Code:
Cells.Replace What:="e", Replacement:="č", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=True, SearchFormat:=False, ReplaceFormat:=False
The recorded VBA code shows that the character to be replaced is not correctly displayed and is actually
"e" and not
"è". Therefore, I tried to paste the character
"è" into the code instead. Unfortunately, this was not successful because after pasting, a question mark ("?") appeared.
Code:
Cells.Replace What:="?", Replacement:="č", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=True, SearchFormat:=False, ReplaceFormat:=False
How can I make a macro that will replace characters correctly?