Microsoft KB Archive/181323

= XL98: Description and Examples of Data Validation =

Article ID: 181323

Article Last Modified on 9/11/2002

-

APPLIES TO


 * Microsoft Excel 98 for Macintosh

-



This article was previously published under Q181323





SUMMARY
Data validation is a new feature that is available in Microsoft Excel 98 Macintosh Edition. It allows you to do the following:
 * Make a list of the entries that restricts the values allowed in a cell.
 * Create a prompt message explaining the kind of data allowed in a cell.
 * Create messages that appear when incorrect data has been entered.
 * Check for incorrect entries by using the Auditing toolbar.
 * Set a range of numeric values that can be entered in a cell.
 * Determine if an entry is valid based on calculation in another cell.



MORE INFORMATION
This article describes some of the ways to use the new data validation feature in Microsoft Excel 98 as well as examples to illustrate how to implement this feature.

NOTE: The examples below assume you are working with a new Microsoft Excel 98 workbook and that you start with the first example and continue through the examples in the order in which they are presented.

Make a List of Entries Allowed in the Cell
You can make a list of the entries you will accept for a cell on a worksheet. You can then restrict the cell to accept only entries taken from the list by using the data validation feature.

To create a drop-down list and restrict values in the cell to these entries, do the following:
 * 1) Select cell A1.
 * 2) On the Data menu, click Validation.
 * 3) On the Settings tab, click List in the Allow list.
 * 4) By default, the Ignore Blank and In-cell check boxes are selected. Do not change them.
 * 5) In the Source box, enter a,b,c.

NOTE: You can also enter a named range or cell reference if it contains a list of values. Both must be preceded by an equal sign.
 * 1) Click OK.

Cell A1 now has a list next to it and you can use this list to select the value to enter in the cell.
 * 1) Click the list, and then click any item it contains.

This value is entered in the cell.

NOTE: You can manually enter a, b , or c in the cell; you do not have to select these from the list. If you try to manually enter anything other these values, a stop message appears and you are unable to keep the value in this cell. Your only options are Retry or Cancel.

Create a Prompt Message Explaining the Type of Data Allowed in a Cell
You can create a message that explains the type of data that can be entered in a cell. When you select the cell, the message appears near the cell. You can move this message, if necessary, and it remains until you move to another cell or press the ESC key. If the Office Assistant is visible, the message appears in a balloon above the Office Assistant.

Continuing with the previous example, follow these steps:
 * 1) Select cell A1.
 * 2) On the Data menu, click Validation, and then click the Input Message tab.

NOTE: Make sure the "Show input message when cell is selected" check box is selected.
 * 1) In the Title box, enter List for cell A1.

This is the title for the message box that appears. It is in bold text.
 * 1) In the Input Message box, enter Please select either a, b or c from the drop-down list.

This is the body of the message that appears.
 * 1) Click OK.

The message appears because cell A1 is selected.
 * 1) Select cell A10.

The list next to cell A1 and the message for cell A1 both disappear.
 * 1) Select cell A1.

Both the list and the prompt message appear next to cell A1.

NOTE: If the Office Assistant is visible, the prompt message appears in a balloon above the Office Assistant.
 * 1) Move the message to another location in the worksheet.

When you select another cell and then select cell A1 again, the message appears in its new location.

NOTE: There is no way to change the formatting for this message.

Create a Message That Appears When Incorrect Data Is Entered
The style of the error message Microsoft Excel displays when you type incorrect data determines whether the restrictions are enforced. You can display a message that prevents you from entering data values except those specified. You can also display explanatory and warning messages that let you to enter out-of-range data, or you can set limits on the data but not display any messages.

Continuing with the previous example, follow these steps:  Select cell A1.  On the Data menu, click Validation, and then click the Error Alert tab.

NOTE: Make sure the "Show error alert after invalid data is entered" check box is selected.

Create a Stop Alert Message
If you create a Stop Alert message and enter invalid data in the cell, your only options are to click Retry or Cancel; you are not allowed to enter invalid data in the cell. To create the message, follow these steps:

 In the Style list, click Stop. In the Title box, enter Warning for cell A1. This is the title for the message box that appears. In the Error Message box, enter The only allowable values for cell A1 are a, b, or c. This is the body of the message that appears and is limited to 225 characters.

Click OK. </li> Manually enter t in cell A1.

The Stop Alert message you created appears and your only options are Retry or Cancel.</li> Click Cancel on the Stop Alert message box.</li> Select cell A1.</li>  On the Data menu, click Validation, and then click the Error Alert tab.

NOTE: Make sure the "Show error alert after invalid data is entered" check box is selected.

Create a Warning Alert Message
If you create a Warning message and enter invalid data in the cell, your options are more flexible than the options for a Stop Alert message. A Warning Alert message has three options: Yes, to allow entry of the invalid data; No, to give you a chance to enter valid data; and Cancel, to remove the invalid entry. To create the message, follow these steps:

 In the Style list, click Warning.</li> In the Title box, enter Warning for cell A1. This is the title for the message box that appears.</li> In the Error Message box, enter The only allowable values for cell A1 are a, b, or c. This is the body of the message that appears and is limited to 225 characters.</li> Click OK.</li></ol> </li> Manually enter j in cell A1.

The Warning message you created appears asking if you want to Continue.</li> Click Yes.

The invalid value of "j" is entered in cell A1.</li> Select cell A1.</li>  On the Data menu, click Validation and then click the Error Alert tab.

NOTE: Make sure the "Show error alert after invalid data is entered" check box is selected.

Create an Information Alert Message
If you create an Information message and enter invalid data in the cell, your options are the most flexible. When an Information Alert message appears, you can click OK to accept the invalid value or you can click Cancel to reject it. To create the message, follow these steps:

 In the Style list, click Information.</li> In the Title box, enter Warning for cell A1. This is the title for the message box that appears.</li> <li>In the "Error message" box, enter The only allowable value for cell A1 are a, b, or c. This is the body of the message that appears and is limited to 225 characters.</li> <li>Click OK.</li></ol> </li> <li>Manually enter p in cell A1. The Information Alert message you created appears and prompts you to accept or reject the value you entered.</li> <li>Click OK.

The invalid value of "p" is entered in cell A1.</li></ol>

Check for Incorrect Entries Using the Auditing Toolbar
After your data is entered, you can look for entries that are outside the limits you set. When you click Circle Invalid Data on the Auditing toolbar, circles appear around cells that contain incorrect entries. If you correct an invalid entry, the circle disappears.

Continuing with the previous example, follow these steps:
 * 1) On the Tools menu, click Customize.
 * 2) In the Customize dialog box, click the Toolbars tab.
 * 3) In the list of Toolbars, select the Auditing check box (if it's not already selected), and then click Close.
 * 4) On the Auditing toolbar, click the Circle Invalid Data control. Cell A1 is circled.
 * 5) Select cell A1.
 * 6) Click the arrow next to cell A1, and then click one of the entries in the list. The circle disappears.

Set a Range of Numeric Values That Can Be Entered in a Cell
You can place limits on the data that can be entered in a cell. You can set minimums and maximums or check for the effect an entry might have on another cell. To set a limits on the data, follow these steps:
 * 1) Select cell A5.
 * 2) On the Data menu, click Validation and click the Settings tab.
 * 3) In the Allow list, click Whole number.
 * 4) In the Data list, click between.
 * 5) In the Minimum box enter 1.
 * 6) In the Maximum box enter 10.

NOTE: You can use cell references for Steps 5 and 6 to specify cells that contain the minimum and maximum values.
 * 1) Click OK.
 * 2) Enter the value 3 in cell A5.

The value is entered without error.
 * 1) Enter the value 33 in cell A5.

Because the data validation settings you created for cell A1 (an Information Alert) do not apply to those for cell A5, you receive a Stop Alert message (which is the default value), and your only options are to click Retry or Cancel.
 * 1) Click Cancel.

The value of 3 appears in the cell.

Determine If Entry Is Valid Based on Calculation in Another Cell
In the Data Validation dialog box you can use a formula, an expression or a reference to a calculation in another cell to determine if the entry you make is valid. To do this, follow these steps: <ol> <li>Enter the value 1 in cell B10.</li> <li>Select cell A10.</li> <li>On the Data menu, click Validation and click the Settings tab.</li> <li>In the Allow list, click Custom.</li> <li>In the Formula box enter the following formula:

=IF(A10>B10,TRUE,FALSE)

NOTE: The formula you enter must begin with an equal sign and must evaluate to either true or false. It is not limited to the IF function.</li> <li>Click OK.</li> <li>Enter the value -1 in cell A10.

You receive a Stop Alert message stating the value is invalid.</li> <li>Click Retry.</li> <li>Enter the value 3 in cell A10.

You do not receive any error message because this value is greater than the value you entered in cell B10.</li></ol>

<div class="references_section">