Checking for Messages in Cells

Written by Allen Wyatt (last updated March 21, 2020)
This tip applies to Excel 97, 2000, 2002, and 2003


Blair has a worksheet divided into two areas: data entry and data verification. The data verification area consists of formulas that check entries using IF statements. If a problem is located, a text message is displayed in a cell in the verification area, otherwise the formula returns a blank. The following is a typical verification formula:

=IF(A1<>5,"Value in A1 is not 5")

The problem is that the data verification area can be quite large, which means it is easy to miss one of the text messages. Blair wondered if there was a way to create a formula that examined the data verification area and returned a single message if there were any other messages in the area.

There are a number of different ways that this problem can be approached. If the data verification area is contiguous, then a simple array formula will do the trick. Enter the following in any empty cell on the worksheet:

=SUM((LEN(ValRange)>0)*1)

Make sure that ValRange is replaced with the range of cells in the data validation area. Also, make sure you enter the formula by pressing Shift+Ctrl+Enter (to denote it is an array formula). The formula returns a value that indicates how many cells in the range have a length that is greater than 0. In other words, it counts the number of cells that have messages visible.

If you prefer to not use an array formula, you can accomplish the same result by using the following regular formula:

=SUMPRODUCT((LEN(ValRange)>0)*1)

The result, again, is the number of cells that have a length greater than 0. Another approach is to use some of the COUNT functions provided by Excel:

=COUNTA(ValRange) - COUNTBLANK(ValRange)

This formula counts the number of cells in the range, and then subtracts the number of blank cells in the range. The result is the number of cells that are non-blank, or those that are displaying messages. A different formulaic approach can be used to determine a simple yes/no response:

=IF(COUNTIF(ValRange,"?*"),"","No ") & "Verification Messages"

If there are no messages in the ValRange, the formula returns "No Verification Messages." If there are messages, it strips the "No" and simply returns "Verification Messages."

It would also be a good idea to apply conditional formatting to your data verification area. While the formulas discussed so far will tell you if there are messages, it won't highlight where those messages are—conditional formatting can pinpoint each message. Select all the cells in the area that contain formulas, and then use conditional formatting to check the length of those cells. If the length is greater than 0, the cell could be formatted to show a red background. This will make any messages in the data verification area much harder to miss when scrolling through the worksheet.

If you are in the mood to completely redesign your worksheet, a more powerful approach would be to do away with the data verification area. You can achieve the same results (checking what is in the data entry area) by using data validation for each of the entry cells. Set up properly, data validation would make sure that the user entered acceptable values into each cell, removing the need for much of the data validation area.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2772) applies to Microsoft Excel 97, 2000, 2002, and 2003.

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

Changing Axis Tick Marks

Create a chart in Excel, and you may find that the tick marks shown on the axes in the chart aren't to your liking. It is ...

Discover More

Anchoring Objects by Default

When you position objects (such as text boxes or graphics) on a page, one of the things you can do is to anchor the ...

Discover More

Dates Updating when Converting

Word allows you to convert documents from WordPerfect format to Word. In doing so, you may notice that some dates in the ...

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

More ExcelTips (menu)

Find and Replace in Headers

Using Find and Replace is something quite routine in Excel, as it easily allows you to find and replace information in ...

Discover More

Searching Through Many Workbooks

If you have a folder that contains dozens or hundreds of workbooks, you may need to search through those workbooks to ...

Discover More

Using Find and Replace to Pre-Pend Characters

Need to add some characters to the beginning of the contents in a range of cells? It's not as easy as you might hope, but ...

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}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. 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 1 + 1?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

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