Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. 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.
Written by Allen Wyatt (last updated January 11, 2025)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021
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, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. You can find a version of this tip for the older menu interface of Excel here: Cleaning Text.
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!
If you need to know the number of columns in a particular range, you can use the COLUMNS worksheet function. This tip ...
Discover MoreSome users have reported problems using the EOMONTH function in later versions of Excel, beginning with Excel 2007. The ...
Discover MoreMost calculations are done using the decimal numbering system. If you need to convert your decimal values to a differing ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2025-01-11 16:29:51
J. Woolley
The TextClean macro in My Excel Toolbox removes ASCII characters 0 through 31 (Tab, CR, LF, etc.) plus ANSI characters 129, 141, 143, 144, and 157. Additional characters can be specified for removal (case-sensitive) including
Alt+nnnn for UNICHAR(nnnn). For more on this subject, see https://excelribbon.tips.net/T006126
The TextSpaceChars macro converts all UNICODE space characters (see Figure 1 below) into a standard ASCII space. For more on this subject, see https://excelribbon.tips.net/T012593
Both macros:
+ Apply to text constants within the current Selection.
+ Retain the format of individual characters (normally).
+ Support Undo (Ctrl+Z).
See https://sites.google.com/view/MyExcelToolbox/
Figure 1.
2025-01-11 07:03:01
Alex Blakenburg
Unfortunately one of the most common character needing to be removed is the non-breaking space character code 160. For this you will need to use substitute refer: https://excelribbon.tips.net/T005132_Trimming_Off_All_Spaces.html
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.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2025 Sharon Parq Associates, Inc.
Comments