Excel's Data Validation command lets you perform validation on entries to set up data validation rules. You can define data that is acceptable for any given cell or range of cells, and input messages or error alerts that display whenever a validated cell is selected. Error alerts can display whenever a validated cell is selected or when a user tries to enter an invalid value. Data Validation only warns you against inputting invalid data?it doesn't stop you from doing so.
Follow the steps in the next exercise to set up the data validation rules. You are setting rules for the Car data in column B on the Detail sheet.
Click cell A12 on the Detail sheet. Type New York and press Enter. In cell A13, type Hard Cover and press Enter. Click cell A13 and then click the Increase Indent button on the Formatting toolbar.
In cells B13:D13, type the numbers 49, 80, and 125.
Select cells B13:D13. This step tells Excel what data you want to validate in the worksheet.
Choose Data, Validation. The Data Validation dialog box opens, as shown in Figure 16.8. This exercise uses all three tabs: Settings, Input Message, and Error Alert.
First, in the Settings tab, click the Allow drop-down arrow and choose Whole Number.
In the Data list, ensure that Between is selected.
In the Minimum box, type 50.
In the Maximum box, type 100.
Click the Input Message tab.
In the Input Message box, type Any whole number from 50 to 100.
Click the Error Alert tab.
In the Error Message box, type Hard cover sales are less than 50 or greater than 100.
Click OK to confirm your entries. Excel shows the following text box next to cell B13: Any whole number from 50 to 100. The next step is to edit an entry to produce invalid data in a cell.
Click cell D13 on the Detail sheet.
Type 35 and press Enter. Good job! Your error alert worked. Excel displays the error message Hard cover sales are less than 50 or greater than 100.
Click the Cancel button to remove the message.
If your worksheet contains any invalid data, you can identify that data by using the Circle Invalid Data feature. You need to display the Formula Auditing toolbar to use the feature. Excel identifies invalid data by marking the data with a red circle. You can correct the invalid data by typing over the data in the cells that contain a red circle.
The instructions in the following To Do exercise step you through circling and correcting invalid data on your worksheet. First you need to enter invalid data for a car expense in the Detail sheet.
Choose Tools, Formula Auditing, Show Formula Auditing Toolbar. Excel displays the Formula Auditing toolbar.
Click the Circle Invalid Data button on the Formula Auditing toolbar. You should see a red circle around the 49 in cell B13 and the 125 in cell D13 (see Figure 16.9). The number 49 in cell B13 is less than 50. The number 125 in cell D13 is greater than 100. Therefore, the data is invalid.
Click cell B13 and type 100. Then press Enter. Click cell D13 and type 95. Then press Enter. The red circle is removed from both cells.
If a red circle still shows in cell B13 and D13, click the Clear Validation Circles button on the Formula Auditing toolbar.
Click the Close (x) button on the Formula Auditing toolbar to close the toolbar.