473,385 Members | 1,661 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,385 developers and data experts.

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

MMcCarthy
14,534 Expert Mod 8TB
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, 1888 views)
File Type: jpg ValuesIsError.jpg (72.3 KB, 2563 views)
File Type: jpg ValuesFind.jpg (71.4 KB, 1738 views)
File Type: jpg FormulasIsError.jpg (80.0 KB, 1458 views)
File Type: jpg FormulasFind.jpg (74.2 KB, 2033 views)
File Type: jpg ValuesClean.jpg (63.2 KB, 1976 views)
May 4 '13 #1
2 6402
NeoPa
32,556 Expert Mod 16PB
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 Expert Mod 8TB
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
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 &...
3
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...
2
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...
5
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...
0
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...
3
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...
5
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...
0
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...
2
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,...
0
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.