Over 2 million + professionals use CFI to learn accounting, financial analysis, modeling and more. Unlock the essentials of corporate finance with our free resources and get an exclusive sneak peek at the first module of each course.
Start Free
What is the CLEAN Function?
The CLEAN Function[1] is categorized under Excel Text functions. The function removes non-printable characters from the given text. As financial analysts, we often import data from various sources and the CLEAN function can help remove nonprintable characters from a supplied text string. It is also useful in removing line breaks.
The function was introduced to remove the non-printable characters represented by numbers 0 to 31 in 7-bit ASCII code, which are often found at the start of data imported into Excel from other applications.
Formula
=CLEAN(text)
The CLEAN function includes the following argument:
Text (required argument) – The worksheet information from which we intend to remove non-printable characters.
Remember that the CLEAN function differs from the TRIM function, as the former eliminates non-printable characters, represented by ASCII numeric codes 0 to 31. On the other hand, the TRIM function helps get rid of additional spaces that are represented by the ASCII numeric code 32.
How to use the CLEAN function in Excel?
The CLEAN function is a built-in function and can be used as a worksheet function in Excel. As a worksheet function, it can be entered as part of a formula in a cell of a worksheet.
To understand the uses of the function, let’s consider a few examples:
Example 1
Suppose we imported some data in the following format:
Using the CLEAN function, we can remove the unwanted characters as shown below:
In all the scenario above, the function removed non-printable characters. It also removed the non-printable characters CHAR(15) and CHAR(12).
If we wish to apply this formula quickly to a large amount of data, we can follow the steps below:
Assuming the data is given in columns A1 to A1000, then right-click the column header “B” and select “Insert” to create a new “B” column.
Now go to B1. Using the SHIFT key, select B1 to B1000. In the example, hold “Shift” and click cell “B1000” to select cells “B1” through “B1000.”
Now, type “=CLEAN(A1)” (excluding the quotes) and then press “Ctrl-Enter” to apply the CLEAN function to the entire selection and clean every data point on our list.
The function will work even if non-printable characters are present in between the data. Suppose, we are given the following data: ‘Monthlyreport’
In such a scenario, we can use the formula CLEAN(Monthlyreport). Using the CLEAN function, we can remove any non-printable data present anywhere between the characters. We get the result shown below:
Example 2
Let’s assume we wish to remove line breaks from cells, we can use TRIM with the CLEAN function as shown below:
In the above example, the data include non-printable characters, as well as line breaks. To clean and trim data, we used formula =TRIM(CLEAN(text)) as shown below:
The CLEAN function lacks the ability to remove all non-printing characters, particularly a non-breaking space, which can appear in Excel as CHAR(160). In such a scenario, adding the SUBSTITUTE function to the formula, we can remove specific characters as shown below:
Here, we used TRIM, CLEAN, and SUBSTITUTE together.
A few things to remember about the CLEAN function
The CLEAN function will give the value with all non-printable characters removed.
The function was introduced in Excel 2000 and is available in all versions after that.
Remember, in the Unicode character set, there are additional non-printing characters. By itself, the CLEAN function does not remove these additional non-printing characters.
Thanks for reading CFI’s guide to important Excel functions! By taking the time to learn and master these functions, you’ll significantly speed up your financial analysis. To learn more, check out these additional CFI resources:
To master the art of Excel, check out CFI’s Excel Crash Course, which teaches you how to become an Excel power user. Learn the most important formulas, functions, and shortcuts to become confident in your financial analysis.
Launch CFI’s Excel Crash Course now to take your career to the next level and move up the ladder!
Take your learning and productivity to the next level with our Premium Templates.
Upgrading to a paid membership gives you access to our extensive collection of plug-and-play Templates designed to power your performance—as well as CFI's full course catalog and accredited Certification Programs.
Gain unlimited access to more than 250 productivity Templates, CFI's full course catalog and accredited Certification Programs, hundreds of resources, expert reviews and support, the chance to work with real-world finance and research tools, and more.