Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, and 2013. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Cleaning Text.

Cleaning Text

by Allen Wyatt
(last updated November 15, 2014)

4

Excel includes an interesting worksheet function whose duty it is to make sure that your text is "clean." By this, Excel means that your text contains only printable characters. Thus, the function removes certain non-printable characters and control codes from your text. The syntax is rather simple, as follows:

=CLEAN(text)

All you need to do is include the text, or a reference to a cell that contains text. In doing some testing, it appears that the function removes anything with an ANSI value of 1 through 31, as well as the values 129, 141, 143, 144, and 157.

So why would you use the CLEAN function? If you import information from some mainframe or on-line services, the non-printable codes could be interspersed in the information you receive. This can cause problems printing or viewing the information correctly. CLEAN can help rectify those problems.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (10350) applies to Microsoft Excel 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Excel here: Cleaning 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

Cut and Paste Formatting

What happens when you copy information from one document and paste it into another? It is possible for what you paste to look ...

Discover More

Placing Formula Results in a Comment

Excel won't allow you to directly or automatically insert the results of a formula into a cell's comment. You can, however, ...

Discover More

Finding Columns of a Certain Width

If you need to find out how many columns are set to be a specific width, you'll need a macro to help determine the info. ...

Discover More

Save Time and Supercharge Excel! Automate virtually any routine task and save yourself hours, days, maybe even weeks. Then, learn how to make Excel do things you thought were simply impossible! Mastering advanced Excel macros has never been easier. Check out Excel 2010 VBA and Macros today!

More ExcelTips (ribbon)

New Worksheet Functions in Excel 2007

Every new version of Excel seems to introduce a few new tools you can use in your formulas. Excel 2007 is no different; this ...

Discover More

Median of Selected Numbers

Need to find a median value in a series of values? It's easy with the MEDIAN function. What isn't as easy is to derive the ...

Discover More

Converting to Octal

If you need to do some work in the base-8 numbering system (octal), you'll love two worksheet functions provided by Excel for ...

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}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 8Mpixels. 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 - 3?

2014-11-18 06:02:33

Willy Vanhaelen

@ Micky

These are printable characters so CLEAN must leave them untouched.

Alt+0254 is the lower case thorn letter: þ still used in Icelandic alphabet (see http://en.wikipedia.org/wiki/Thorn_%28letter%29)

Alt+0160 is a non breaking space, often used in HTML, it prints like a space.


2014-11-17 11:36:49

Michael (Micky) Avidan

@Willy,
The TWO most frequent non-printable characters I have met are:
Alt+0254 and: Alt+0160.
If I recall correctly - the CLEAN function does not even "tickles" them.
Michael (Micky) Avidan
“Microsoft® Answers" - Wiki author & Forums Moderator
“Microsoft®” MVP – Excel (2009-2015)
ISRAEL


2014-11-16 06:53:13

Willy Vanhaelen

Trim acts on spaces: character 32.
Clean removes non printable characters.
See Help for more details.


2014-11-15 23:54:04

venkat

what is the difference betwen TRIM and CLEAN


This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu 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.