473,612 Members | 2,115 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to use the CLEAN, FIND and ISERROR Worksheet Functions in Excel

MMcCarthy
14,534 Recognized Expert Moderator MVP
There are so many functions available in Excel Worksheets that users often stick with the most common ones until they start exploring trying to find a solution to a problem. Sometimes it doesn't even occur to them that there may be a function to deal with the issue. So I decided to draw on my experience to note some of the lessor known functions I have found to be very useful.

As the title of this article suggests these are Excel Worksheet functions for use in cell formula as opposed to VBA functions. Although some may also be available in VBA the are not as a rule. Where the function is available in VBA I will state it.

CLEAN()

The CLEAN function is used to "Clean" text. We've all had those situations when users copy a body of text from the web or some text document and paste it into a cell in Excel. The text often ends up interspersed with unprintable characters. This function can be used to remove all those characters.

The clean function removes ASCII characters 1-31, 129, 141, 143, 144, and 157. The only ones it doesn't remove are CHAR(127) and CHAR(160)

The syntax for the function is:
CLEAN ( Cell Reference of Text )

In this first image you can see the formulas I used to test the function. In Cell Reference A1 I inserted ASCII Character 9 before a block of text and ASCII

Character 13 at the end of it. In Cell Reference A2 I entered the Clean Function and passed it the Value in A1. I then entered the Len() function in column B to evaluate the length of the text in the corresponding row of Column A.



In the below image you can see the values when I turn off the Formula display. As you can see the length of the Text in Column A decreases by 2 to indicate the removal of the two non-printing characters once I use the Clean function.



FIND()

The FIND function is used to search for the position of a substring in a body of text. One thing to note is that this function is case sensitive. Also if it doesn't find the substring it is searching for the function will return a #VALUE error. If you need to return a value such as 0 if the substring is not found you can use the ISERROR function to evaluate the result. I outline this function in more detail later in this Article.

The syntax for the function is:
FIND ( substring, Body of Text Reference, [start_position] )
Note: start_position is optional. If no value is entered it defaults to 1, the first character of the Body of Text.

In the first image you can see the formulas entered in column B to search for the substring "the" in the text in the corresponding row in column A.



In the below image you can see the values when I turn off Formula display. The first one returns an error because the "the" in the sentence has a Capital letter T and as previously mentioned the function is case sensitive. The second row shows a value of 12 which is the position in the text that "the" starts and the third row again returns an error because it can't find the substring "the".



ISERROR()
(Can also be used in VBA, see Note on ISERR function)

The ISERROR function is used to discover if a cell contains an error value. It can be used to test to see if a formula returns an error value, a link is broken, etc. It tests for #N/A, #VALUE!, #REF!, #DIV/0!, #NUM!, #NAME? and #NULL. If any of these are found the function returns True otherwise it returns False.

The syntax for the function is:
ISERROR ( Value )

A practical example of how to use this function can be demonstrated with an extension of the example used in the FIND function above.

In the first image you can see I used the ISERROR function in an IF statement in column C to evaluate the result of the FIND Function.



In the below image you can see if the FIND function in column B returns an error then column C shows a 0, otherwise it shows the value returned by the FIND function.



Note: ISERR() is a worksheet function that does the same thing but it cannot be used in VBA, whereas ISERROR() can be used in either.


Mary McCarthy
Bytes Admin
Attached Images
File Type: jpg FormulasClean.jpg (64.6 KB, 1914 views)
File Type: jpg ValuesIsError.jpg (72.3 KB, 2582 views)
File Type: jpg ValuesFind.jpg (71.4 KB, 1745 views)
File Type: jpg FormulasIsError.jpg (80.0 KB, 1463 views)
File Type: jpg FormulasFind.jpg (74.2 KB, 2049 views)
File Type: jpg ValuesClean.jpg (63.2 KB, 1982 views)
May 4 '13 #1
2 6427
NeoPa
32,566 Recognized Expert Moderator MVP
SEARCH() is similar to FIND() but not case-sensitive.
SUBSTITUTE() is one of my favourites. Very similar to the VBA function Replace(), which is quite different from the worksheet function REPLACE().
May 10 '13 #2
MMcCarthy
14,534 Recognized Expert Moderator MVP
I removed the last paragraph and changed the thread title to make it a better search result. I'll look at doing another thread with SEARCH, SUBSTITUTE and REPLACE.
May 13 '13 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
8253
by: Vanessa | last post by:
Hi In my VB Dot Net program, I'm using Automation to call Excel worksheet to do some insert some data. I have rename my worksheet to a name. eg. "ABC". How do I insert the worksheet name & Page No to the Footer so that when I print the worksheet, the name of the worksheet and page number will be printed out as well?
3
9237
by: sridevi | last post by:
Hello How to export data from ms-access database to excel worksheet using ASP. mainly i need to export data to multiple worksheets. it is very urgent to us. i have a sample code which works only exporting to single worksheet. but i need to export data to multiple worksheets. it is very urgent to us. so please help me in code.
2
15320
by: xhenxhe | last post by:
I don't some Excel automation. I've created a program that opens and Excel template and inputs information to it. It runs great on my machine. When I build and deploy I have a user that keep getting the error message: "Object reference not set to an instance of an object." Here is the code that generates the message: Dim xlApp As Excel.Application Dim xlBook As Excel.Workbook Dim xlSheet As Excel.Worksheet
5
7868
by: Elena | last post by:
I need the VB.NET code to change the header/footer of an Excel spread sheet, ASAP. I am doing it through a VB application. I can change the ranges/cell values using code, but I do not know how to change things outside of the cell ranges. I will try and post in an Excel group, but i do not need to change it in a worksheet, I need to change it through a VB application. For example, I am using this code to change values in certain cells: ...
0
3664
by: vinidimple | last post by:
Hi i have a serious problem while i was working in Excel.I want to fetch columns from an excel worksheet and i need to compare it with an sql querry fields,so i tried to open an excle worksheet first.. Unfortunately my code was throwing error like
3
3996
by: dan_roman | last post by:
Hi, I developed a script with a nice interface in Tkinter that allows me to edit some formulas and to generate an Excel worksheet with VBA macros within it. The script runs perfectlly in Office 2000, but in Office 2003 crash at line: "wbc = workbook.VBProject.VBComponents.Add(1)" Please help me :-( the code of the module that crash is (only in Excel 2003, in 2000 not): import os
5
3837
by: 14276674 | last post by:
I wrote a program in C that implemens a database. Now I want to upgrade the program so the user can import an excel worksheet and not have to fill in the entire database. How do you import data from an excel worsheet using C. Thanx
0
3039
by: blainegray | last post by:
Greetings This is one of those Access is not closing Excel problems. The first time through the code works fine. The second time there is a problem. After lots of combinations, I finally determined that if I take out the line that copies the temp array to cells in a worksheet, Access will close the Excel file. If the line is there, Excel remains open and blocks more runs of the same procedure. If I close Access, Excel gets closed. Looks like...
2
2301
by: Steve Kershaw | last post by:
Hello, I've been trying to spin off an Excel worksheet on the client from an ASP.NET website. I was successfull in displaying an Excel worksheet on the client in a test website (not using IIS, but using Visual Studio 2005) with the following code: protected void Button1_Click(object sender, EventArgs e) { Application exc = new Application();
0
2702
by: jwmaiden | last post by:
Have an application that opens up a webbrowser control to display data in an Excel spreadsheet (using VB.NET in VS 2005). No problem with opening the spreadsheet or displaying the data, but I'm having problems with repeating the process. I want to create an Excel spreadsheet, add some data to it, and display the results in a webbrowser control. I want to be able to then later delete the old Excel spreadsheet, create a new one, add some new data,...
0
8162
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8105
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8605
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8246
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7039
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6076
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4109
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2550
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1413
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.