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.

Converting to ASCII Text

Written by Allen Wyatt (last updated September 1, 2018)
This tip applies to Excel 97, 2000, 2002, and 2003


1

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:

=CLEAN(A1)

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.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

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.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Entering Calculations in a Form Field

One of the many uses for Word is to create forms that can be easily filled in by other people. This is made possible by ...

Discover More

Exiting a For ... Next Loop Early

If you use For ... Next loops in your macros, make sure you give a way to jump out of the loop early. That way you can ...

Discover More

Copying Data without Leaving the Currently Selected Cell

Copying from one cell to another is easy when editing your worksheet. Doing the copying without selecting a cell other ...

Discover More

Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!

More ExcelTips (menu)

Pulling Apart Characters in a Long String

You can easily use formulas to pull apart text stored in a cell. For instance, if you need to pull individual characters ...

Discover More

Shortening ZIP Codes

US ZIP Codes can be of two varieties: five-digits or nine-digits. Here's how to convert longer ZIP Codes to the shorter ...

Discover More

Breaking Up Variable-Length Part Numbers

Part numbers can often be long, made up of other component elements. Breaking up part numbers into individual components ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 6 - 0?

2018-11-22 14:24:52

Lily marconnet

I tried the clean function but its not working for me :( anything else you could advise? thank you!


This Site

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.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.