Don't Allow Empty Cells

Written by Allen Wyatt (last updated November 4, 2023)
This tip applies to Excel 97, 2000, 2002, and 2003


Merle is trying to use the Data Validation feature of Excel to limit what a user can choose in a cell. When the user activates a cell he only wants an answer of Yes, No, or N/A; he does not want the user to be able to get out of the cell and leave it blank (empty). Merle has set up a list for the acceptable values (Yes, No, and N/A) and has unchecked the Ignore Blanks check box when setting up the Data Validation.

The problem is that when someone activates the cell, it is possible for them to still leave it empty. The only time that Excel won't allow the person to leave the cell blank is if they start to edit the cell and try to leave it blank after the edit. Merle wants, once the cell is selected, for the user to absolutely only be able to leave the cell if they choose Yes, No, or N/A.

Data Validation, by itself, can't take care of this. There are a couple of ways that you can work around the problem, however. The first idea is to modify the options that you give the user. For instance, let's say that you add a fourth choice of "Provide Answer." You could then change the value in the cell to the same value and save your workbook. When the user opens it, the cell contains "Provide Answer" and, once they select the cell, they won't be able to blank it out; they will need to provide an answer.

Another option is to use a macro in conjunction with the Data Validation you have set up. The easiest method is to set up an event handler for each time the selection changes in the worksheet. The following example kicks into play if the cell selection is C22 (which is where your Data Validation should be, as well).

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim rng As Range
    Set rng = Range("C22")
    If Application.Intersect(Target, rng) Is Nothing Then
        MsgBox "You must select the answer from the list"
    End If
End Sub

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (8767) 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

Selecting a Language

Need to format a paragraph (or some selected text) so that it is a language other than English? You can do so easily by ...

Discover More

Getting Rid of "Copy of"

When you save a read-only workbook file under a new name, Excel automatically adds "copy of" to the beginning of that ...

Discover More

Automatic Sound Clips

Want to add some sound to your documents? It's easy. What isn't so easy is configuring a sound clip to play whenever a ...

Discover More

Professional Development Guidance! Four world-class developers offer start-to-finish guidance for building powerful, robust, and secure applications with Excel. The authors show how to consistently make the right design decisions and make the most of Excel's powerful features. Check out Professional Excel Development today!

More ExcelTips (menu)

Changing Fonts in Data Validation Drop-Down Lists

The data validation capabilities of Excel allow you to easily create drop-down lists showing what data is acceptable for ...

Discover More

Using Data Validation

Want to control what users put into a cell? It's easy to do using a feature called data validation, as described in this tip.

Discover More

Stopping Validated Data from being Overwritten

Data Validation is a great tool to make sure that data entered in a cell meets whatever criteria you decide. Its ...

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 7 + 0?

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.