0% found this document useful (0 votes)
55 views9 pages

Validation

The document provides a comprehensive guide on how to use Excel's data validation features to restrict and validate data entry in cells. It covers setting validation rules for whole numbers, customizing warning messages, and creating lists with dependent values using the Indirect function. Additionally, it explains how to edit validations, identify cells with validations, and trace cells that violate validation rules.

Uploaded by

Yared Addisu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views9 pages

Validation

The document provides a comprehensive guide on how to use Excel's data validation features to restrict and validate data entry in cells. It covers setting validation rules for whole numbers, customizing warning messages, and creating lists with dependent values using the Indirect function. Additionally, it explains how to edit validations, identify cells with validations, and trace cells that violate validation rules.

Uploaded by

Yared Addisu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Cell Validation

Introduction
Excel allows you to restrict data entry to cells to numbers, dates, or values from a list, then
let’s you validate the information being entered to ensure it matches the restrictions set.

Setting a Validation Rule on a Cell


Let’s restrict entry in a cell to whole numbers:

1. Open a new, blank Excel workbook.


2. In cell A1 type Age.
3. Click in cell B1.
4. Click on the Data tab and select [Data Validation] from the Data Tools section – it
is the middle button right above ‘Data Tools’.
The Data Validation window appears:

5. On the Settings tab, in the Validation criteria area, use the pulldown for Allow to
select the option Whole number.
6. Further settings appear: enter a Minimum: of 0 and a Maximum: of 100
7. Click [OK].
Note** You do have to set up the minimum and maximum values. Excel will not let them
remain blank. However, you are not restricted to entering fixed values for there, you can also
enter an equals sign and then reference data cells.
8. Now type the word ‘Excel’ into cell B1.

The following warning appears:

\
9. Click on [Retry] and type ‘-75’.
10. Click on [Retry].
11. Type a whole number between 0 and 100.

Note** Excel will not check validation in a Data Form.

Customizing the Warning Message


The warning message shown above isn't very helpful. It tells you that the value that you
entered is not valid, but doesn't tell you why. Excel does allow you to customize the message to
make it more user friendly.

12. Click in cell B1.


13. Click on [Data Validation ] from the Data tab.
14. Click on the Error Alert tab.
Note** Excel provides three different levels of error alert: Stop will only accept valid data;
Warning allows the user to enter invalid data if they click a button; Information accepts invalid
data.

15. Using the pull down on Style: select Warning.


16. In the Title box type ‘Please Note:’.
17. In the Error message: box type: You should only use whole numbers between
0 and 100.
18. Click on [OK].
19. Now type ‘Excel’ into cell B1.
20. Click [No].
21. Type ‘101’ into the cell.
22. Click [Yes]. Because we chose Warning rather than Stop, it will allow the invalid
data if you tell it to.

Setting Warning Messages on a Cell


Sometimes it is better to warn the user before they enter data, rather than give them an error
message after the data has already been entered.

23. Click on cell C1.


24. On the Data tab, click on [Data Validation].
25. Enter validation for a whole number between 0 and 100.
26. Click on the Input Message tab, and you should see the following:
27. The box for ‘Show input message when cell is selected’ should be checked.
28. In the Title box, type ‘Your Age:’ and press [Tab].
29. In the Input Message: box type: Enter your age to the nearest whole number.
30. Click on [OK].

Now when you click on cell C1 you will see the message displayed. The cell has to be active for
the message to show.

31. Click on cell E3 to see that the message no longer displays.

Copying Validation Across Cells


You can set validation on a whole group of cells by selecting them prior to creating the
validation, but you can also copy a validation from one cell to the others:

32. Click on cell B1 then right click and choose Copy.


33. Now select the cells B2 to B5.
34. Right click and choose Paste Special... (click on the words – there isn't an icon)
35. Under the Paste heading click on Validation then click on [OK].

This will copy just the validation to the cells. Do NOT now press [Enter] or you will paste
again, but this time you’ll paste ALL the cell properties, including the data.

Note** If you use relative cell references in a validation, if you paste the validation to another
cell or cells, the reference will change relative to the new position. To prevent this, absolute
references (e.g. $B$1) must be used.

Non-Numeric Validations
You can use Excel for other validations besides whole numbers, such as numbers with decimal
points, dates or times and text (up to a specific number of characters). You can also restrict the
entry to a fixed list of values (numeric or non-numeric).

Let’s try a date:

36. Click in cell A6 and type the word Birthday.


37. Click in cell B6 and open [Data Validation] as you did earlier.
38. On the Settings tab, use the pulldown on Allow: and select Date.
39. For the Start date: type 1 Jan.
40. For the End date: type 31 Dec.
41. Click [OK].
42. Now type your own birthday (just month and day) into cell B6.
43. Press [Enter].
44. Click on cell B6. Notice what the date is in the formula bar. Because you did not
enter a year, Excel defaulted to the current year because it needs to have a year on
a date.
45. Enter your birthdate including the year.
46. Correct the validation by adding a start year of 1900 and an end year of 2016.
47. Enter your actual date of birth in cell B6.
Now let’s use a list:

48. Click in cell A7 and type Gender.


49. Click in cell B7 and open [Data Validation].
50. On the Settings tab, use the pulldown on Allow: and select List.
51. Note that the Ignore Blank checkbox is selected – it was selected AND grayed out
before you chose List. This means someone can leave the cell blank. If the field is
required (it isn’t in this case), uncheck this box.
52. In the Source box type Male, Female, Other (make sure you use the comma to
separate them).
53. Click [OK] – a pulldown arrow is now attached to the cell.
54. Use the pulldown to select your Gender. (Please note that this category is used only
for example purposes and makes no assumption about gender identification in any
way.)

For limiting text:

55. Click in cell A8 and type Username.


56. Click in cell B8 and open [Data Validation].
57. On the Settings tab, use the pulldown on Allow: and select Text length.
58. Using the pulldown on Data: select less than or equal to.
59. Enter a Maximum: value of 8.
60. Click [OK].
61. Type ‘advancedexcel’ in cell B8 and press [Enter].
62. Click [Retry] then type in your asurite and press [Enter].

Note** You can also limit text to a range of characters by keeping the Data setting between
and then entering a minimum and maximum value.

Lists and Sub-Lists


Now that you’ve used lists to restrict entry to cells, let’s look at how the value selected from one
list can be used to set the values available in another list by using the Indirect function. Please
note that this section uses data just as example and makes no assumptions about gender
identification in any way.

63. Move to cell K1 and type Men - press [right_arrow]


64. In cell L1 type Women - press [Enter]
65. In cells L2 to L6 type five names you identify as female.
66. In cells K2 to K5 type four names you identify as male.
Next, we’ll name the cell ranges:

67. Highlight cells L2 to L6 then click in the Name Box (above column A), type Women
and press [Enter].
68. Highlight cells K2 to K5, name the range Men and press [Enter].
69. Click in cell H1 and open [Data Validation].
70. On the Settings tab, use the pulldown on Allow: and select List.
71. Click in the Source box then highlight cells K1 to L1.
72. Click [OK].

Note** You have to set up this validation first in order for the second list setup to work,
otherwise you’ll get an error message.

73. Click in cell H2 and open [Data Validation].


74. On the Settings tab, use the pulldown on Allow: and select List.
75. Click in the Source box then type =Indirect(H1).
76. Click [OK]

The Indirect function uses the value shown in cell H1 (men or women) to define list that shows
in cell H2.

77. In cell H1, select Men.


78. Cell H2 should show your list of men’s names.
79. Move back to H1 and select Women.
80. Cell H2 should show your list of women’s names.

Obviously a user would have to select the value in cell H1 before being able to choose a value
in H2. When using this type of validation that must be kept in mind, but using Indirect can be
useful for things like setting up surveys. In the case of a survey, you would also want to hide
the named ranges (the lists of names in this case) by either hiding the columns or using white
for the font color.

For more tips about using lists and validation, watch the lecture video.
Customized Validations
All Excel validations test whether a criteria is TRUE or FALSE. If you want to set a validation
that does not already have an option in Data Validation, you can set up your own validation
test.
To set a budget with specific expense limits:

81. Move to cell A10 and type Budget - press [Tab]


82. In cell B10 enter the expenditure limit of 20 - press [Enter]
83. Select cells B10 to B14 and apply the Accounting style (on the Home tab, click the
dollar sign in the Number area).
84. In cell A11 type Food, in cell A12 type Drink, in cell A13 type Tip and in cell A14
type Total.
85. Click in cell B14 and enter a formula to calculate the total of cells B11 through B13.

Note** Validation cannot be set on cell B14 since the validation check is performed on the
data entry and cell B14 contains calculated values. The validation must instead be set on the
cells that are used in the calculation.

86. Highlight cells B11 to B13.


87. Open [Data Validation].
88. On the Settings tab, use the pulldown on Allow: and select Custom
89. In the new Formula: box that appears type: = $B$14<=$B$10 (Note** you must
use absolute references).

Tip** You can create an absolute reference from a normal reference by pressing <F4> once
after you’ve typed the reference and before you’ve hit [Enter] or typed anything else.

90. Type an Error message: titled ‘Budget Error’, indicating that Expenditure must be
within the budget.
91. Click on [OK].
Now if the total calculated in cell B14 exceeds $20 the message will appear.
92. Enter amounts that total less than $20.00

If you want to test alternatives, you can use the OR function, while if you want to do a joint
test you can use the AND function.

Let’s restrict the tipping level in the budget.

93. Highlight cells B11 to B13.


94. Open [Data Validation].
95. Change the Error message: to read Expenditure must be within the budget
and tips no higher than 20% of the total cost
96. On the Settings tab, change the Formula: to =AND($B$14<=$B$10, $B$13<=
$B$14*20%) then press [Enter] or click on [OK].

Editing Validations
Suppose you want to change an existing validation. If you have multiple cells that contain the
same validation test, Excel lets you update it in all the cells at the same time.

Suppose 20% was too large, and we need to change the tip level to 15%:

97. Click in cell B12 (Note** You could do this with any of the validation cells).
98. Open [Data Validation].
99. On the Settings tab, change 20% in the Formula to 15%.
100. At the bottom of the window, make sure the check box for “Apply these
changes to all other cells with the same settings” is selected.
101. Edit the Error Message to reflect the new 15%.
102. Click on [OK].

Identifying Cells with Validations


Before updating the validation in multiple cells, it can be helpful to check which cells will be
affected. Excel has a mechanism that can show you either all cells that contain any validation or
just those cells with the same validation setting.

103. From the Home tab, click on the [Find & Select] button on the far right.
104. Select Data Validation and any cell that contains validation will be displayed
with light blue shading.
105. Click on cell B12.
106. Click on [Find & Select] again but this time choose Go To Special…
107. Select Data validation and then select the Same.
108. Click [OK] to see only the cells with validation settings that match those for B12.

Tracing Cells which Violate Validations


Excel also allows you to check for data values which violate certain conditions. This can be
invaluable when you want to check a large data set for errors because you can select the data,
set up a validation then trace the errors.
109. Move to cell B10 and set a budget lower than the current total in B14.
110. Move to cell B1 and type 101 ([Enter]) - click on [Yes] to override the
validation.
The worksheet doesn't show any problems because the validation is only carried out on data
entry.
However, you can force a validation check on all cells:

111. From the Data tab, use the pulldown on [Data Validation] to select Circle
Invalid Data. This will circle in red any cells with invalid values.

Click on the File tab, save the file to your computer, then answer the validation assessment
based on your file and/or comprehension of the lecture.

You might also like