0% found this document useful (0 votes)
92 views26 pages

Data Validation in Excel 2007 - Drop Down List: Admin

The document describes how to create a data validation drop down list in Excel 2007. It provides steps to select a cell, open the Data Validation dialog box, set the validation to a list and enter valid values either manually or by referring to a range of cells. It also describes options to ignore blanks, display input and error messages, and apply the validation settings to multiple cells.

Uploaded by

Evelyn Arado
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
92 views26 pages

Data Validation in Excel 2007 - Drop Down List: Admin

The document describes how to create a data validation drop down list in Excel 2007. It provides steps to select a cell, open the Data Validation dialog box, set the validation to a list and enter valid values either manually or by referring to a range of cells. It also describes options to ignore blanks, display input and error messages, and apply the validation settings to multiple cells.

Uploaded by

Evelyn Arado
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 26

Data validation in Excel 2007 Drop down list

AUGUST 13, 2009 BY ADMIN

If you want to validate a cell to restrict data entry to values in a drop-down list follow these steps: 1. 2. Select the cell you want to validate. On the Data tab, in the Data Tools group, click Data Validation.

3.

The Data Validation dialog box will open.

4. 5. 6.

In the Data Validation dialog box, click the Settings tab. Click on the Allow box then select List from the drop-down list. Click the Source box and then type the valid values separated by the appropriate list separator character depending on your installation( usually a comma , or semicolon ;). For example if the cell is for a color of a car then you can limit the values by entering : Silver, Green, Blue.

7. 8.

Instead of typing your list manually, you can also create the list entries by referring to a range of cells in the same worksheet or another worksheet in the workbook. To specify the location of the list of valid entries, do one of the following: a. b. If the list is in the current worksheet, enter a reference to your list in the Source box, for example enter: =$A$1:$A$6. If the list is on a different worksheet, define a name for your list then enter the name that you defined for your list in the Source box, for example, enter: =ValidProjects.

Notes: 1. 2. 3. Make sure that the In-cell dropdown check box is selected. Otherwise, you wont be able to see the drop-down arrow next to the cell. To specify how you want to handle blank (null) values, select or clear the Ignore blank check box. If your allowed values are based on a cell range that has a defined name and there is a blank cell anywhere in that range, selecting the Ignore blank check box allows any value to be entered in the validated cell. This is also true for any cells that are referenced by validation formulas: if any referenced cell is blank, selecting the Ignore blank check box allows any value to be entered in the validated cell. More Validation options: 1. Display an input message when the cell is clicked. a. b. c. 2. Click the Input Message tab. Select Show input message when cell is selected check box. Fill in the Title and text for the Input message.

Display an error message when wrong data is entered.

a. b. c. d.

Click the Error Alert tab. Select Show error alert after invalid data is entered check box. Fill in the Title and text for the Error message. Select one of the following options for the Style box: 1. 2. 3. Information: Display an information message. Does not prevent entry of invalid data. Warning: Display a warning message. Does not prevent entry of invalid data. Stop : Prevent entry of invalid data.

Tip If you change the validation settings for a cell, you can automatically apply your changes to all other cells that have the same settings. To do so 1. 2. 3. Open the Data Validation dialog box. Click the Settings tab. Select the Apply these changes to all other cells with the same settings check box.

How to validate a cell value


APRIL 8, 2008 BY ADMIN

If you are designing an excel sheet for other users to enter data, or even for your own use, it is a good idea to use the data validation feature to insure that only correct data will be entered. hear is how you do it: 1. 2. Select the cell you want to validate. On the Data menu, click Validation, the Data Validation dialogue box will be shown.

3. 4.

Click the Settings tab. Specify the type of validation you want. Suppose you have a numeric value and you want to allow only values between 1 and 99, then: a. b. c. d. In the Allow combo box select Decimal. In the Data combo box select Between. In the Minimum edit box enter 1. In the Maximum edit box enter 99.

To show an error message when an invalid data is entered: 1. Click the Error Alert tab.

2.

Fill the Title and Error Message edit boxes with appropriate text. (See example).

To remove data validation, click the Clear All button in the Settings tab.

Hello, i am running EXCEL 2007. i am trying to make an if statement that accomplishes something like, If c1=b1 then d1 = pick a choice from the data validation list(drop down list) that is from e1 to e5. else pick a choice from the data validation list(drop down list) that is from f1 to f5. i am new to running macros in excel. pls advise how i need to insert a macro for a particular cell and then copy it to the other cells below it i.e for d2,d3..etc to chk for c2,c3,..etc thanks you have validation in the cells E1 to E5 and also F1 to F5 type the following formula in D1 =IF(C1=B1,E1,F1) if there is not entry in E1 or F1 (that is if you have not used the validation) then D1 will be zero once you choose a validation is used to enter a value in E1 or F1 then D1 will change accordingly. try some experiments copyp D1 down upto D5.

Custom data validation in Excel 2007: To understand the power of data validation, you should use the 'custom' setting. The following video describes the use of the 'custom' setting. Let's assume for example that you wish to ensure that the cells c2 to c10 under the heading 'price' contain only numerical data. We will now use the 'ISNUMBER' function to solve this problem. The 'ISNUMBER' function returns the boolean value 'TRUE' if the function refers to an Excel cell that contains numeric data and it retutns 'FALSE' if the function refers to a cell that has a non-numeric value.

Now we select the cells c2:C10, click on the 'data' tab in the ribbon, then click data validation in the Data Tools group and finally fill in the 'Settings' tab - under 'Allow' we fill in 'custom' and under 'Formula' we fill in '=ISNUMBER(C2). We click 'OK' to finalize our work. Now if we try to enter non-numerical data into the cell c2:c10 we receive an error prompt.

Apply data validation to cells


You use data validation to control the type of data or the values that users enter into a cell. For example, you may want to restrict data entry to a certain range of dates, limit choices by using a list, or make sure that only positive whole numbers are entered. This article describes how data validation works in Excel and outlines the different data validation techniques available to you. It does not cover cell protection, which is a feature that lets you "lock" or hide certain cells in a worksheet so that they can't be edited or overwritten. For more information about how to protect cells, see the links in the See Also section.

WHAT IS DATA VALIDATION?


Data validation is an Excel feature that you can use to define restrictions on what data can or should be entered in a cell. You can configure data validation to prevent users from entering data that is not valid. If you prefer, you can allow users to enter invalid data but warn them when they try to type it in the cell. You can also provide messages to define what input you expect for the cell, and instructions to help users correct any errors. For example, in a marketing workbook, you can set up a cell to allow only account numbers that are exactly three characters long. When users select the cell, you can show them a message such as this one:

If users ignore this message and type invalid data in the cell, such as a two-digit or five-digit number, you can show them an actual error message. In a slightly more advanced scenario, you might use data validation to calculate the maximum allowed value in a cell based on a value elsewhere in the workbook. In the following example, the user has typed $4,000 in cell E7, which exceeds the maximum limit specified for commissions and bonuses.

If the payroll budget were to increase or decrease, the allowed maximum in E7 would automatically increase or decrease with it. Data validation options are located in the Data Tools group.

You configure data validation in the Data Validation dialog box.

TOP OF PAGE

WHEN IS DATA VALIDATION USEFUL?


Data validation is invaluable when you want to share a workbook with others in your organization, and you want the data entered in the workbook to be accurate and consistent. Among other things, you can use data validation to do the following:

Restrict data to predefined items in a list

For example, you can limit types of departments to Sales, Finance, R&D, and IT.

Similarly, you can create a list of values from a range of cells elsewhere in the worksheet. For more information, see Create a dropdown list from a range of cells.

Restrict numbers outside a specified range of children in a particular cell. Restrict dates outside a certain time frame today's date. Restrict times outside a certain time frame

For example, you can specify a minimum limit of deductions to two times the number

For example, you can specify a time frame between today's date and 3 days from

For example, you can specify a time frame for serving breakfast between the time

when the restaurant opens and 5 hours after the restaurant opens. Limit the number of text characters For example, you can limit the allowed text in a cell to 10 or fewer characters. Similarly, you

can set the specific length for a full name field (C1) to be the current length of a first name field (A1) and a last name field (B1), plus 10 characters.

Validate data based on formulas or values in other cells

For example, you can use data validation to set a maximum limit for

commissions and bonuses of $3,600, based on the overall projected payroll value. If users enter more than $3,600 in the cell, they see a validation message.
TOP OF PAGE

DATA VALIDATION MESSAGES


What users see when they enter invalid data into a cell depends on how you have configured the data validation. You can choose to show an input message when the user selects the cell. This type of message appears near the cell. You can move this message, if you want to, and it remains until you move to another cell or press ESC.

Input messages are generally used to offer users guidance about the type of data that you want entered in the cell. You can also choose to show an error alert that appears only after users enter invalid data.

You can choose from three types of error alerts:

ICON

TYPE Stop

USE TO Prevent users from entering invalid data in a cell. A Stop alert message has two options: Retry or Cancel. Warn users that the data they entered is invalid, without preventing them from entering it. When a Warning alert message appears, users can click Yes to accept the invalid entry, No to edit the invalid entry, or Cancel to remove the invalid entry. Inform users that the data they entered is invalid, without preventing them from entering it. This type of error alert is the most flexible. When an Information alert message appears, users can click OK to accept the invalid value or Cancel to reject it.

Warning

Information

You can customize the text that users see in an error alert message. If you choose not to do so, users see a default message. Input messages and error alerts appear only when data is typed directly into the cells. They do not appear under the following conditions:

A user enters data in the cell by copying or filling. A formula in the cell calculates a result that is not valid. A macro enters invalid data in the cell.
TOP OF PAGE

How to handle a data validation alert


When you try to enter or change data in a worksheet cell, you see a data validation error alert. This alert signifies that the owner of the workbook applied data validation to the cell to prevent users from entering invalid data, and implemented the error alert to let you know that the data you entered is invalid. You can enter only valid data in cells that have data validation applied. If you are not clear about the validity of the data that you can enter, you should contact the owner of the workbook. If you inherited the workbook, you can modify or remove the data validation unless the worksheet is protected with a password that you do not know. If possible, you can contact the previous owner to help you unprotect the worksheet. You can also copy the data to

another worksheet, and then remove the data validation. For more information about how to change or remove data validation, see Change data validation settings or Remove data validation.

TIPS FOR WORKING WITH DATA VALIDATION


In the following list, you will find tips and tricks for working with data validation in Excel.

If you plan to protect the worksheet or workbook, protect it after you have finished specifying any validation settings. Make sure that you unlock any validated cells before you protect the worksheet. Otherwise, users will not be able to type any data in the cells. If you plan to share the workbook, share it only after you have finished specifying data validation and protection settings. After you share a workbook, you won't be able to change the validation settings unless you stop sharing, but Excel will continue to validate the cells that you have designated while the workbook is being shared.

You can apply data validation to cells that already have data entered in them. However, Excel does not automatically notify you that the existing cells contain invalid data. In this scenario, you can highlight invalid data by instructing Excel to circle it on the worksheet. Once you have identified the invalid data, you can hide the circles again. If you correct an invalid entry, the circle disappears automatically.

To quickly remove data validation for a cell, select it, and then open theData Validation dialog box (Data tab, Data Tools group). On the Settingstab, click Clear All. To find the cells on the worksheet that have data validation, on the Hometab, in the Editing group, click Find & Select, and then click Data Validation. After you have found the cells that have data validation, you can change, copy, or remove validation settings. When creating a drop-down list, you can use the Define Name command (Formulas tab, Defined Names group) to define a name for the range that contains the list. After you create the list on another worksheet, you can hide the worksheet that contains the list and then protect the workbook so that users won't have access to the list. If data validation isn't working, make sure that: Users are not copying or filling data Data validation is designed to show messages and prevent invalid entries only when users

type data directly in a cell. When data is copied or filled, the messages do not appear. To prevent users from copying and filling data by dragging and dropping cells, clear the Enable fill handle and cell drag-and-drop check box (Excel Options dialog box, Advanced options), and then protect the worksheet. Manual recalculation is turned off click Automatic. Formulas are error free Make sure that formulas in validated cells do not cause errors, such as #REF! or #DIV/0!. Excel ignores the If manual recalculation is turned on, uncalculated cells can prevent data from being validated

correctly. To turn off manual recalculation, on the Formulas tab, in the Calculation group, clickCalculation Options, and then

data validation until you correct the error. Cells referenced in formulas are correct If a referenced cell changes so that a formula in a validated cell calculates an invalid

result, the validation message for the cell won't appear.


TOP OF PAGE

Add data validation to a cell or range


In the next sections, you will learn the different techniques for adding validation to cells in a worksheet.

Restrict data entry to values in a drop-down list Restrict data entry to a whole number within limits Restrict data entry to a decimal number within limits

RESTRICT DATA ENTRY TO VALUES IN A DROP-DOWN LIST


It is not possible to change the font or font size for items in a list. Select one or more cells to validate. On the Data tab, in the Data Tools group, click Data Validation.

Restrict data entry to a date within a time frame Restrict data entry to a time within a time frame Restrict data entry to text of a specified length Calculate what is allowed based on the content of another cell Use a formula to calculate what is allowed

1. 2.

1. 2. 3. 4. 5. Issue: The Data Validation command is unavailable.

In the Data Validation dialog box, click the Settings tab. In the Allow box, select List. Click the Source box and then type the list values separated by the Microsoft Windows list separator character (commas by default). 1. For example:

To limit entry to a question, such as "Do you have children?", to two choices, type Yes, No. To limit a vendor's quality reputation to three ratings, type Low, Average, High. 1. 2. You can also create the list entries by referring to a range of cells elsewhere in the workbook. For more information, see Create a drop-down list from a range of cells. NOTE The width of the drop-down list is determined by the width of the cell that has the data validation. You might need to adjust the width of that cell to prevent truncating the width of valid entries that are wider than the width of the drop-down list.

6. 7.

Make sure that the In-cell dropdown check box is selected. Otherwise, you won't be able to see the drop-down arrow next to the cell. To specify how you want to handle blank (null) values, select or clear theIgnore blank check box. 1.
NOTE

If your allowed values are based on a cell range that has a defined name and there is a blank cell anywhere in that range,

selecting the Ignore blank check box allows any value to be entered in the validated cell. This is also true for any cells that are referenced by validation formulas: if any referenced cell is blank, selecting the Ignore blank check box allows any value to be entered in the validated cell. 8. Optionally, display an input message when the cell is clicked. 1. 9. How to display an input message

Specify how you want Microsoft Office Excel to respond when invalid data is entered. 1. How to specify a response to invalid data

10. Test the data validation to make sure that it is working correctly. Try entering both valid and invalid data in the cells to make sure that your settings are working as you intended and your messages are appearing when you expect. Tip If you change the validation settings for a cell, you can automatically apply your changes to all other cells that have the same

settings. To do so, open theData Validation dialog box, and then select the Apply these changes to all other cells with the same settings check box on the Settings tab.

RESTRICT DATA ENTRY TO A WHOLE NUMBER WITHIN LIMITS


1. 2. Select one or more cells to validate. On the Data tab, in the Data Tools group, click Data Validation.

1. 2. 3. 4. 5. 6. Issue: The Data Validation command is unavailable.

In the Data Validation dialog box, click the Settings tab. In the Allow box, select Whole number. In the Data box, select the type of restriction that you want. For example, to set upper and lower limits, select between. Enter the minimum, maximum, or specific value to allow. You can also enter a formula that returns a number value. 1. For example, to set a minimum limit of deductions to two times the number of children in cell F1, select greater than or equal to in the Databox and enter the formula, =2*F1, in the Minimum box.

7.

To specify how you want to handle blank (null) values, select or clear theIgnore blank check box. 1.
NOTE

If your allowed values are based on a cell range with a defined name, and there is a blank cell anywhere in the range,

setting theIgnore blank check box allows any values to be entered in the validated cell. This is also true for any cells that are referenced by validation formulas: if any referenced cell is blank, setting the Ignore blank check box allows any values to be entered in the validated cell. 8. Optionally, display an input message when the cell is clicked. 1. 9. How to display an input message

Specify how you want Microsoft Office Excel to respond when invalid data is entered. 1. How to specify a response to invalid data

10. Test the data validation to make sure that it is working correctly. Try entering both valid and invalid data in the cells to make sure that your settings are working as you intended and your messages are appearing when you expect. Tip If you change the validation settings for a cell, you can automatically apply your changes to all other cells that have the same

settings. To do so, open theData Validation dialog box, and then select the Apply these changes to all other cells with the same settings check box on the Settings tab.

RESTRICT DATA ENTRY TO A DECIMAL NUMBER WITHIN LIMITS


1. 2. Select one or more cells to validate. On the Data tab, in the Data Tools group, click Data Validation.

1. 1. 3. 4. Issue: The Data Validation command is unavailable.

In the Data Validation dialog box, click the Settings tab. In the Allow box, select Decimal.

5. 6.

In the Data box, select the type of restriction that you want. For example, to set upper and lower limits, select between. Enter the minimum, maximum, or specific value to allow. You can also enter a formula that returns a number value. 1. For example, to set a maximum limit for commissions and bonuses of 6% of a salesperson's salary in cell E1, select less than or equal to in the Data box and enter the formula, =E1*6%, in the Maximum box.

NOTE

To let a user enter percentages, for example 20%, selectDecimal in the Allow box, select the type of restriction that you

want in the Data box, enter the minimum, maximum, or specific value as a decimal, for example .2, and then display the data validation cell as a percentage by selecting the cell and clicking Percent Style 7. in theNumber group on the Home tab.

To specify how you want to handle blank (null) values, select or clear theIgnore blank check box. 1.
NOTE

If your allowed values are based on a cell range with a defined name, and there is a blank cell anywhere in the range,

setting theIgnore blank check box allows any values to be entered in the validated cell. This is also true for any cells that are referenced by validation formulas: if any referenced cell is blank, setting the Ignore blank check box allows any values to be entered in the validated cell. 8. Optionally, display an input message when the cell is clicked. 1. 9. How to display an input message

Specify how you want Microsoft Office Excel to respond when invalid data is entered. 1. How to specify a response to invalid data

10. Test the data validation to make sure that it is working correctly. Try entering both valid and invalid data in the cells to make sure that your settings are working as you intended and your messages are appearing when you expect. Tip If you change the validation settings for a cell, you can automatically apply your changes to all other cells that have the same

settings. To do so, open theData Validation dialog box, and then select the Apply these changes to all other cells with the same settings check box on the Settings tab.

RESTRICT DATA ENTRY TO A DATE WITHIN A TIME FRAME


1. 2. Select one or more cells to validate. On the Data tab, in the Data Tools group, click Data Validation.

1. 2. 3. 4. 5. 6. Issue: The Data Validation command is unavailable.

In the Data Validation dialog box, click the Settings tab. In the Allow box, select Date. In the Data box, select the type of restriction that you want. For example, to allow dates after a certain day, select greater than. Enter the start, end, or specific date to allow. You can also enter a formula that returns a date. 1. For example, to set a time frame between today's date and 3 days from today's date, select between in the Data box, enter =TODAY() in theMinimum box, and enter =TODAY()+3 in the Maximum box.

7.

To specify how you want to handle blank (null) values, select or clear theIgnore blank check box. 1.
NOTE

If your allowed values are based on a cell range with a defined name, and there is a blank cell anywhere in the range,

setting theIgnore blank check box allows any values to be entered in the validated cell. This is also true for any cells that are

referenced by validation formulas: if any referenced cell is blank, setting the Ignore blank check box allows any values to be entered in the validated cell. 8. Optionally, display an input message when the cell is clicked. 1. 9. How to display an input message

Specify how you want Microsoft Office Excel to respond when invalid data is entered. 1. How to specify a response to invalid data

10. Test the data validation to make sure that it is working correctly. Try entering both valid and invalid data in the cells to make sure that your settings are working as you intended and your messages are appearing when you expect. Tip If you change the validation settings for a cell, you can automatically apply your changes to all other cells that have the same

settings. To do so, open theData Validation dialog box, and then select the Apply these changes to all other cells with the same settings check box on the Settings tab.

RESTRICT DATA ENTRY TO A TIME WITHIN A TIME FRAME


1. 2. Select one or more cells to validate. On the Data tab, in the Data Tools group, click Data Validation.

1. 2. 3. 4. 5. 6. Issue: The Data Validation command is unavailable.

In the Data Validation dialog box, click the Settings tab. In the Allow box, select Time. In the Data box, select the type of restriction that you want. For example, to allow times before a certain time of day, select less than. Enter the start, end, or specific time to allow. You can also enter a formula that returns a time. For example, to set a time frame for serving breakfast between the time when the restaurant opens (the value in cell H1) and five hours after that, select between in the Data box, enter =H1 in the Minimum box, and then enter =H1+"5:00" in the Maximum box.

7.

To specify how you want to handle blank (null) values, select or clear theIgnore blank check box.
NOTE

If your allowed values are based on a cell range with a defined name, and there is a blank cell anywhere in the range, setting

the Ignore blank check box allows any values to be entered in the validated cell. This is also true for any cells that are referenced by validation formulas: if any referenced cell is blank, setting the Ignore blank check box allows any values to be entered in the validated cell. 8. Optionally, display an input message when the cell is clicked. 1. 9. How to display an input message

Specify how you want Microsoft Office Excel to respond when invalid data is entered. 1. How to specify a response to invalid data

10. Test the data validation to make sure that it is working correctly. Try entering both valid and invalid data in the cells to make sure that your settings are working as you intended and your messages are appearing when you expect.

Tip

If you change the validation settings for a cell, you can automatically apply your changes to all other cells that have the same

settings. To do so, open theData Validation dialog box, and then select the Apply these changes to all other cells with the same settings check box on the Settings tab.

RESTRICT DATA ENTRY TO TEXT OF A SPECIFIED LENGTH


1. 2. Select one or more cells to validate. On the Data tab, in the Data Tools group, click Data Validation.

1. 2. 3. 4. 5. Issue: The Data Validation command is unavailable.

In the Data Validation dialog box, click the Settings tab. In the Allow box, select Text Length. In the Data box, select the type of restriction that you want. For example, to allow up to a certain number of characters, select less than or equal to.

6.

Enter the minimum, maximum, or specific length for the text. You can also enter a formula that returns a number value. For example, to set the specific length for a full name field (C1) to be the current length of a first name field (A1) and a last name field (B1) plus 10, select less than or equal to in the Data box and enter=SUM(LEN(A1),LEN(B1),10) in the Maximum box.

7.

To specify how you want to handle blank (null) values, select or clear theIgnore blank check box.
NOTE

If your allowed values are based on a cell range with a defined name, and there is a blank cell anywhere in the range, setting

the Ignore blank check box allows any values to be entered in the validated cell. This is also true for any cells that are referenced by validation formulas: if any referenced cell is blank, setting the Ignore blank check box allows any values to be entered in the validated cell. 8. Optionally, display an input message when the cell is clicked. 1. 9. How to display an input message

Specify how you want Microsoft Office Excel to respond when invalid data is entered. 1. How to specify a response to invalid data

10. Test the data validation to make sure that it is working correctly. Try entering both valid and invalid data in the cells to make sure that your settings are working as you intended and your messages are appearing when you expect. Tip If you change the validation settings for a cell, you can automatically apply your changes to all other cells that have the same

settings. To do so, open theData Validation dialog box, and then select the Apply these changes to all other cells with the same settings check box on the Settings tab.

CALCULATE WHAT IS ALLOWED BASED ON THE CONTENT OF ANOTHER CELL


1. 2. Select one or more cells to validate. On the Data tab, in the Data Tools group, click Data Validation.

1.

2. 3. 4. 5. 6.

Issue: The Data Validation command is unavailable.

In the Data Validation dialog box, click the Settings tab. In the Allow box, select the type of data that you want. In the Data box, select the type of restriction that you want. In the box or boxes below the Data box, click the cell that you want to use to specify what is allowed. For example, to allow entries for an account only if the result won't go over the budget in cell E4, select Decimal for Allow, select less than or equal to for Data, and in the Maximum box, enter =E4.

7.

To specify how you want to handle blank (null) values, select or clear theIgnore blank check box.
NOTE

If your allowed values are based on a cell range with a defined name, and there is a blank cell anywhere in the range, setting

the Ignore blank check box allows any values to be entered in the validated cell. This is also true for any cells that are referenced by validation formulas: if any referenced cell is blank, setting the Ignore blank check box allows any values to be entered in the validated cell. 8. Optionally, display an input message when the cell is clicked. 1. 9. How to display an input message

Specify how you want Microsoft Office Excel to respond when invalid data is entered. 1. How to specify a response to invalid data

10. Test the data validation to make sure that it is working correctly. Try entering both valid and invalid data in the cells to make sure that your settings are working as you intended and your messages are appearing when you expect. Tip If you change the validation settings for a cell, you can automatically apply your changes to all other cells that have the same

settings. To do so, open theData Validation dialog box, and then select the Apply these changes to all other cells with the same settings check box on the Settings tab.

USE A FORMULA TO CALCULATE WHAT IS ALLOWED


1. 2. Select one or more cells to validate. On the Data tab, in the Data Tools group, click Data Validation.

1. 2. 3. 4. 5. Issue: The Data Validation command is unavailable.

In the Data Validation dialog box, click the Settings tab. In the Allow box, select Custom. In the Formula box, enter a formula that calculates a logical value (TRUE for valid or FALSE for invalid entries). For example:

1. TO MAKE SURE THAT 3. The cell for the picnic account (B1) can only be updated if nothing is budgeted for the discretionary account (D1)

2. ENTER THIS FORMULA 4. =AND(D1=0,D2<40000)

and the total budget (D2) is less than the $40,000 allocated. 5. The cell that contains a product description (B2) only contains text. 7. For the cell that contains a projected advertising budget (B3), the subtotal for subcontractors and services (E1) must be less than or equal to $800, and the total budget amount (E2) must also be less than or equal to $97,000. 9. The cell that contains an employee age (B4) is always greater than the number of full years of employment (F1) plus 18 (the minimum age of employment). 11. All the data in the cell range A1:A20 contains unique values. 6. =ISTEXT(B2)

8. =AND(E1<=800,E2<=97000)

10. =IF(B4>F1+18,TRUE,FALSE)

12. =COUNTIF($A$1:$A$20,A1)=1 13. You must enter the formula in the data validation for cell A1, and then fill the cells A2 though A20 so that the data validation for each cell in the range has a similar formula, but the second argument to theCOUNTIF will match the current cell. 15. =AND(LEFT(B5, 3) ="ID-",LEN(B5) > 9)

14. The cell that contains a product code name (B5) always begins with the standard prefix of ID- and is at least 10 characters long.
6.

To specify how you want to handle blank (null) values, select or clear theIgnore blank check box.
NOTE

If your allowed values are based on a cell range with a defined name, and there is a blank cell anywhere in the range, setting

the Ignore blank check box allows any values to be entered in the validated cell. This is also true for any cells that are referenced by validation formulas: if any referenced cell is blank, setting the Ignore blank check box allows any values to be entered in the validated cell. 7. Optionally, display an input message when the cell is clicked. 1. 8. How to display an input message

Specify how you want Microsoft Office Excel to respond when invalid data is entered.

1. 9.

How to specify a response to invalid data

Test the data validation to make sure that it is working correctly. Try entering both valid and invalid data in the cells to make sure that your settings are working as you intended and your messages are appearing when you expect. Tip If you change the validation settings for a cell, you can automatically apply your changes to all other cells that have the same

settings. To do so, open theData Validation dialog box, and then select the Apply these changes to all other cells with the same settings check box on the Settings tab.
TOP OF PAGE

Validate numbers, dates, times, and text


In case you didn't read the previous column, you use the Data Validation dialog box (Data menu, Validation command) to create validation rules and control what users enter on your worksheets. That dialog box also provides a common set of options for validating whole numbers, decimals, dates and times, and text. The following figure illustrates the key point: If you select Whole number, Decimal,Date, Time, or Text length from the Allow list, the Data list provides the options shown here.

For example, you can require a whole number between 1 and 25, a date between 2000 and 2002, or a text string no more than 200 characters long. And don't worry about setting an incorrect rule. Excel won't let you.
NOTE

If you select Any value, List, or Custom from the Allow list, the Data list becomes unavailable. I'll explain how to use Any

value and Custom later on. See the previous column if you want to know how to create lists. The following steps explain one way to validate whole numbers. Keep in mind that if you require a whole number, that's what users have to enter. They can't enter a decimal, a date, or text. If you require a date, users can only enter a date, and so on.

To validate whole numbers


1. 2. 3. 4. On your practice worksheet, select a blank cell, and then, on the Datamenu, click Validation. Click the Settings tab, and from the Allow list, select Whole number. From the Data list, select between. In the Minimum box, type 1. In the Maximum box, type 30, and then clickOK.

5.

Try to enter a number larger than 30 in the text box. Excel prevents you from entering the invalid value. You have to either enter a valid number or leave the cell empty.

To validate dates, times, and text

Follow the steps listed above, but select Date, Time, or Text length from the Allow list. Depending on your selection, the lists, text boxes, and other controls on the Settings tab will change. Use those options to create the validation rules you want. Take a little time to experiment with the choices. It's painless!

Create custom input and error messages


The previous steps reveal a potential problem: Even if you know that a cell contains a validation rule, how do you know which values to enter? One answer is to place instructions in an adjacent cell, but you don't always have room to do that. In that case, you can create custom input and error messages. The input messages appear when the user selects a cell that contains a data validation rule, and the error messages appear when the user enters an invalid value.
NOTE

Excel provides a default error message that works well (in my humble opinion), but you really should place instructions in

adjacent cells or create input messages. They'll make your worksheets much easier to use and help ensure accurate data.

To create input and error messages


1. 2. 3. 4. 5. 6. 7. Click the cell that contains the validation rule you created in the previous section, and then open the Data Validation dialog box. Click the Input Message tab, and then, in the Title box, type this text:Limited Values. In the Input message box, type this text: Enter whole numbers between 1 and 30. Click the Error Alert tab, and in the Title box, type Incorrect Value. In the Error message box, type this text: You entered an invalid number. Enter a whole number between 1 and 30. Click OK, and then select the cell. The input message appears whenever you select the cell. Try to enter a value greater than 30 in the cell. The error message allows you to either type a valid number or leave the cell blank.

Ensure that your error messages prevent users from making mistakes
When you create an error message, you can select one of the following message styles.

The default style is Stop. If you select any of the other styles, users can enter invalid data. The other styles display either the warning icon or the information icon . Use the warning message style to help your users avoid mistakes, such as entering the

wrong kind of data. Use the information message style when you think your users can benefit from some additional instructions. For example, you may want to remind them to enter dates in the mm/dd/yyyy format.

NOTE

Regardless of your error message, data validation isn't a completely foolproof way of ensuring that users enter correct values.

Users can overcome your validation rules by copying entries and pasting them into your restricted cells. If you need to find invalid entries, see Check worksheets for invalid data, later in this column.

Copy validation rules to other cells


You use the Paste Special dialog box to copy validation rules to other cells.

To copy validation rules


1. 2. 3. 4. 5. Select the cell that you want to copy. Press CTRL+C, or on the Edit menu, click Copy. Select the cell into which you want to paste the rules. On the Edit menu, click Paste Special. The Paste Special dialog box appears. Click Validation, and then click OK.

Check worksheets for invalid data


Because users can defeat your validation rules with a simple copy-and-paste operation, it's a good idea to check the worksheets that others use for invalid data. Follow these steps: 1. 2. On the Tools menu, point to Formula Auditing, and then click Show Formula Auditing Toolbar. On the toolbar, click the Circle Invalid Data button .

Excel circles any entries on the active worksheet that violate your validation rules, like so.

When you find errors, you can change them yourself or send the workbook back to the person who entered the invalid data and ask them to correct it.

Remove validation rules


1. 2. 3. 4. Select the cell or range of cells that contains the data validation settings that you want to remove. On the Data menu, click Validation. Click Clear All, or from the Allow list, select Any value. Click OK.
NOTE

If the cell has an input message applied, you must also disable or delete the message. If you don't, it appears whenever users

select that cell. Your users then have to take the time to close the message. I'm reasonably sure they'll also become irritated with you in the process. To disable the message, click the Input Message tab, clear the Show input message when cell is selected check box, and then click OK. If you're feeling a bit more ambitious, you can delete the message title and text instead.

About the Custom criteria and using formulas


You use the Custom validation criteria when you want to use data-validation formulas. You follow the same process discussed earlier in this column:

Open the Data Validation dialog box, select Custom from the Allow list, and then enter your formula in the Source box. Excel does not provide functions specifically for data validation. Instead, you use the standard functions to control data entry. For example, to ensure that a range of cells in column B contain only text, you would enter this formula in the Data Validation dialog box: =ISTEXT(B1:B10) A number of Web sites and good books provide data-validation formulas. Rather than reinvent the wheel, I'll just point you to some of them:

Excel Data Validation Sample (a sample worksheet from Microsoft, complete with instructions)

As an alternative to using INDIRECT to create dependent Excel data validation lists, you can use the non-volatile INDEX function. In this example, just 4 dynamic range names are used. Of these, 3 are used to create the basic framework of the method. The fourth permits any number of subsidiary lists to be created to act as Dependent dropdown lists from the entry in the previous column, without having to define individual names for each list. Create Named Lists 1. In a new Workbook, rename Sheet 1 as Data Entry 2. Rename Sheet2 as Lists 3. Enter Headings on the Data Entry sheet in cells A1:D1 -- Region, Country, Area and City Data Entry Sheet

4. On the Lists sheet in cell A1 add the headings Regions. 5. In cells A2:A5 enter APAC, MEA, Europe and Americas. (These first 2 headings represent Asia & Pacific, Middle East & Africa) Lists Sheet

Create the Dynamic Ranges Select sheet Lists and then go through the following processes to create the 4 Dynamic range names that are required:

Master - which will be used for the validation in column A of Data Entry ValData - which will define the range on Sheet Lists that contains the Validation Data Counter - which will be used to determine the length of each Validation List UseList - which is used for all columns where validation is required on Sheet Data Entry, apart from column A

Create the First Dynamic Range Our first List is going to be called Master 1. Choose Insert | Name | Define 2. Type a name for the first range -- Master 3. In the Refers To box, enter an Index formula that defines the range size, based on the count of items in column A of the Lists sheet: =Lists!$A$2:INDEX(Lists!$A:$A,COUNTA(Lists!$A:$A)) 4. This will give a dynamic List starting with cell A2 and extending for as many entries as we create in column A Add More Headings and Entries to Lists Enter all the Region names as headings in cells B1:E1 of the Lists Sheet. Then, under each Region heading, enter one or more countries from that region. (See screen shot below, or see the sample file)

Create the ValData Dynamic Range On the Lists sheet is the range of data that will be used in all validations for the Data Entry sheet. Instead of referring to the sheet name as range for this data, which will grow as more validations are added, you'll create a Dynamic range. 1. Choose Insert | Name | Define 2. Type a name for the range -- ValData 3. In the Refers To box, enter an Index formula that defines the range size, choosing say 100 rows and a count of the columns on the sheet =Lists!$A$2:INDEX(Lists!$1:$100,100,COUNTA(Lists!$1:$1) ) 4. This will give a dynamic List starting with cell A2 and extending for 100 rows and as many entries as we create in Row 1 5. Click the Add button The choice of 100 rows is arbitrary, and should just be sufficient to contain whatever is going to be the longest of your lists. Next, because each individual List can have a different number of values, we need to create a Counter. Create a Counter The Counter is a variable which defines the length of each individual List. It is dynamic, and will alter dependent upon which column is being used, the column being returned by the Match function. A dynamic range will be created for the Counter. Note: The range is relative, and refers to the cell to the left (A2) to determine its values, so it is vital that you have the cursor in cell B2

of the Data Entry sheet when defining the range. 1. On the Data Entry sheet, type Europe in cell A2 (this is a temporary value, and you can delete it later) 2. On the Data Entry sheet, select cell B2 3. Choose Insert | Name | Define 4. Type a name for the range -- Counter 5. In the Refers To box, enter an Index formula that defines the range size, based on the count of numbers in the relevant column: =COUNTA(INDEX(ValData,,MATCH('Data Entry'!A2,Lists!$1:$1,0))) 6. Click the Add button Create the UseList Dynamic Range This is the universal list name that will apply to all lists that are added to the sheet other than the Master list as previously described. As new columns are added to the Lists sheet, their relevant used range is automatically dynamically created, and using UseList as the data source will apply to the whole of the validation areas on sheet Data Entry. Note: Because the range is relative, and refers to the cell to the left (A2) to determine its values, it is vital that you have the cursor in cell B2 of the Data Entry sheet when defining the range. 1. Place your cursor in cell B2 of Data Entry sheet. 2. Choose Insert | Name | Define 3. Type a name for the range -- UseList 4. In the Refers To box, enter the following formula =INDEX(ValData,1,MATCH('Data Entry'!A2,Lists!$1:$1,0)): INDEX(ValData,Counter,MATCH('Data Entry'!A2,Lists!$1:$1,0)) 5. Click the Add button Why the Cursor Placement is Important

ValData has previously been defined as a range beginning in Row 2 of the Lists sheet. The UseList formula indexes the Valdata range, with 1 fixed value for the starting row element, in the first part of the formula and 1 dynamic value for the ending row element, in the second part of the formula. The formula has 1 relative value for the column element of the Index in both parts of the formula. Row in the first part is determined by the 1 in (Valdata,1, ...) and will therefore refer to Row 1 of

ValData (therefore, row 2 of the Lists sheet).

Row in the second part is determined by Counter in (Valdata,Counter, ...) , and Counter is a previously defined count, which will vary according to the number of entries in the validation list for the relative column. Column is determined by the Match of whatever is in the cell to the left of the cell using this dynamic range, MATCH('Data Entry'!A2,Lists!$1:$1,0) with the values of the List headings held in row 1 of the Lists sheet.

That is why it is so important to place the cursor in the correct starting cell when creating this named range. Setup the Validation cells for Column A on Data Entry Now that you've defined the dynamic ranges, the next step is to set up the validation ranges on the Data Entry sheet. 1. On the Data Entry sheet, select cells A2:A12 (or as many rows as you require) 2. Choose Data | Validation 3. Choose Allow | List 4. In the Source box, type =Master 5. Click OK

Setup the Validation cells for all other columns on Data Entry The next step is to set up the remaining validation ranges on sheet Data Entry 1. On the Data Entry sheet, select cells B2:D12 (or as many rows as you require) 2. Choose Data | Validation 3. Choose Allow | List 4. In the Source box type =UseList 5. Click OK The finished Data Entry sheet with sample Data

Expanding Columns on sheet Lists You can add as many extra columns as you wish on sheet Lists. Each column has to have a heading which is a member of one of the other columns on the sheet, so that the new column added will be Dependent upon that heading. For example, you could add a heading for US, and type a list states in that column. Next, you could add the state names as headings in row 1, and type a list of city names for each state. You do not need to define any new names, as the Uselist dynamic range name will automatically deal with that for you.

The INDIRECT worksheet function is a useful tool for creating cell or range references "on the fly", as a formula is evaluated, rather than "hard coding" them into the formula. Microsoft's on-line Help documentation of this function only hints at is usefulness. In its simplest usage, the INDIRECT function allows you to put the address of one cell in another, and get data from the the first cell by referencing the second. For example, if cell A1 has the value "C3", then =INDIRECT(A1) will return the value in C3.

The real power of the INDIRECT function is that it can turn any string into a reference. This includes any string that you build up using string constants and the values of other cells in the formula, strung together with the & concatenation operator. For example, the simple formula =SUM(A5:A10) will sum the values in the range A5:A10. However, suppose you want to be able to specify which range of rows to sum "on the fly", without having to change the formula. The INDIRECT function allows you to do this. Suppose you put your starting row cell B1, and your ending row in C1. Then, you can use the formula =SUM(INDIRECT("A"&B1&":A"&C1)) The argument to the INDIRECT function is "A"&B1&":A"&C1 If B1 contains 5 and C1 contains 10, this evaluates to the string "A5:A10". The INDIRECT function converts this string to an actual range reference, which is passed to the SUM function. For VBA formulas to return relative sheet names (e.g., the name of the next or previous worksheet), see the Referencing Worksheets From Formulas page. Another useful feature of the INDIRECT function is that since it takes string argument, you can use it to work with cell references that you don't want Excel to automatically change when you insert or delete rows. Normally, Excel will change cell references when you insert or delete rows or columns, even when you use absolute referencing. If you have the formula =SUM($A$1:$A$10), and then insert a row at row 5, Excel will convert the formula to =SUM($A$1:$A$11). If you don't want this to happen, use the INDIRECT function to change a text string to a reference: =SUM(INDIRECT("A1:A10")) Since Excel sees "A1:A10" as a text string rather than a range reference, it will not change it when rows or columns are deleted or inserted. This feature is important when working with some array formulas. Frequently, an array formula will use the ROW() function to return an array of numbers. For example, the following formula will return the average of the 10 largest numbers in the range A1:A60 : =AVERAGE(LARGE(A1:A60,ROW(1:10))) However, if you insert a row between rows 1 and 10, Excel will change the formula to =AVERAGE(LARGE(A1:A60,ROW(1:11))) which will return the average of the 11 largest numbers. If we use the function with a string, Excel won't change the reference, so the formula will remain correct, regardless of whether and where rows are inserted or deleted. =AVERAGE(LARGE(A1:A60,ROW(INDIRECT("1:10"))))

You can use the INDIRECT function in conjunction with the ADDRESS function. The ADDRESS function uses row and column numbers to create a string address. For example, the formula =ADDRESS(5,6) returns the string $F$5, since $F$5 is the 5th row of column 6. You can use then pass this to INDIRECT to get the value in cell F5. For example, =INDIRECT(ADDRESS(5,6)) . While this example may seem trivial, it illustrates a technique that you can use to build more complicated formulas.

You might also like