Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Converting to ASCII Text.
by Allen Wyatt
(last updated April 11, 2016)
Brenda has a lot of information that has been imported or pasted into a worksheet. Sometimes the text in the worksheet will contain "foreign" and strange characters. She wonders if there is a way to easily convert the data so that it contains no non-ASCII characters and, perhaps, some foreign characters are converted to regular ASCII values (such as converting accented letters to non-accented letters).
There are a couple of things you can try. First, you can use the CLEAN worksheet function to get rid of non-printable characters. Just use the function in this manner:
The result is "cleaned" text, without the non-printables. If you want to replace foreign characters with regular ASCII characters, that will need to be done with a macro. Here's an example of a relatively straightforward approach:
Sub StripAccent() Dim sAcc As String Dim sReg As String Dim sA As String Dim sR As String Dim i As Integer sAcc = "ŠŽšžŸÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðñòóôõöùúûüýÿ" sReg = "SZszYAAAAAACEEEEIIIIDNOOOOOUUUUYaaaaaaceeeeiiiidnooooouuuuyy" For i = 1 To Len(sAcc) sA = Mid(sAcc, i, 1) sR = Mid(sReg, i, 1) Selection.Replace What:=sA, Replacement:=sR, _ LookAt:=xlPart, MatchCase:=True Next End Sub
The macro steps through the characters in the sAcc variable and, one at a time, uses Find and Replace to replace them with the corresponding character in the sReg variable. You can adjust the contents of sAcc and sReg to reflect your conversion needs; the key is to make sure that they are both the same length.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (11492) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Converting to ASCII Text.
Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!
Excel works with decimal values very easily. It is more difficult for the program to work with non-decimal values, such as ...Discover More
You know what time it is, right? (Quick—look at your watch.) What if you want to know what time it is in Greenwich, ...Discover More
If you import information generated on a UNIX system, you may need to figure out how to change the date/time stamps to ...Discover More
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.