Data Validation in ExcelMS Excel is the most popular spreadsheet software with a wide range of features, formulas, and functions. Data Validation is one of the essential features in MS Excel. When creating an Excel sheet for users or customers, we may often need to restrict the inputs based on different criteria to ensure that all the entries or inputs are correct and consistent. Data Validation is the solution that helps us control user inputs into specific cells or a range according to the specified rules. In this article, we discuss the feature Data Validation in Excel and the method to insert/ apply it within the Excel sheet. The article also explains relevant examples with images to help us understand the concepts of Data Validation clearly. What is Data Validation?Data Validation is an essential Excel feature that helps control or restrict user inputs/ entries in selected cells. It enables users to set the desired validation rules to control what type of data they can enter into the corresponding cells in an Excel sheet. For instance, we can restrict users to enter values between 1 to 10, enter names or passwords in less than 30 characters, enter or choose an entry from the predefined list of acceptable values, and more. Some of the essential tasks (restrictions/ validations) that we can set using the Data Validation are as follows:
Note: It should be noted that the data validation feature is not a completely reliable way to control input and can be easily defeated. If we copy data from cells with no validation rules and then paste those cells to cells with data validation, the validation is destroyed. Specifically, validation rules are removed or changed from the corresponding cell based on the copied cells.How does Data Validation work in Excel?Applying Data Validation on any cell or range of cells in an Excel sheet restricts the users from entering any undesired entries in corresponding cells based on the validation rules. For instance, if we set validation to accept only numbers or numeric values, other users or we will not be able to enter any values other than numbers. Data Validation can be configured to show an input message to users when the respective cell is selected, informing them what is allowed in it, as shown below: As soon as we try to enter any other type of data in restricted cells, Excel instantly displays an error message and even can display which type of data the respective cells can accept. The error message can be of different styles and customized or created manually while setting up the validation rules on the Excel sheet. Data Validation ControlsThe Data Validation feature or its controls can be found on the ribbon under the Data tab. By default, it is placed under the category 'Data Tools'. As soon we click the 'Data Validation' icon from the ribbon, it immediately launched a Data Validation dialogue box. In addition to the Data Validation shortcut on the ribbon, we can also use the keyboard shortcut 'Alt + D + L' without quotes. It will launch the Data Validation dialogue box instantly. Using Data Validation Dialog Box to Define Validation RulesThe Data Validation dialogue box contains three essential options/ tabs: Settings, Input Message, and Error Alert. Let us understand each tab in detail: Settings TabThe settings tab provides us options to set validation criteria. The tab helps us choose the desired validation rules from the built-in options we want to allow in selected cells. Moreover, we can also set custom rules with the customized formula to validate user inputs. The settings tab contains all the data validation options present in Excel. Input Message TabThe input message tab has a text box to enter a message displayed as soon as the respective cell is selected. The input message is an optional feature of Data Validation. If we do not define any message as an input message, excel does not show any message when the user selects the respective cell with data validation. It does not affect the working of the data validation and has no effect or control over what the user enters into a cell. However, it can be helpful to inform users about the allowed or expected data values. Error Alert TabThe error alert tab provides us options to control the way how the validation is enforced. We can set criteria and then use any desired error style to accept or reject the user inputs accordingly. Additionally, we can also display a message to the user informing what the error is or what values must be entered in corresponding cells. There are currently three types of error styles in MS Excel, as listed below:
Data Validation OptionsWhen creating a data validation rule from the settings tab, we have eight options to validate user inputs. They are as follows:
Apart from the validation options, the settings tab also displays two checkboxes:
How to add Data Validation in Excel?To add a data validation in an Excel sheet, we must perform the following steps: Step 1: Launch the Data Validation dialogue BoxFirst, we must select all the cells or a range to which we wish to apply validation. Next, we need to navigate the Data tab - Data Tools group and select 'Data Validation' to launch the data validation dialogue box. Step 2: Set the Data Validation RuleAfter the data validation dialogue box is displayed, we need to go to the Settings tab to define validation criteria. We can provide the desired values, cell references, or formulas in the validation criteria. Suppose we need to restrict users to enter marks for each student, but the marks must be supplied in between 0 to 100. This way, we can eliminate the chances of wrong inputs to some extent. For this, we need to set the criteria in the Settings tab as the following image: After all the validation settings have been set, we need to click the OK button to close the validation dialogue box or move to the next tab to insert an input message and/or error alerts. The other two tabs are optional and used to inform users to enter appropriate values according to the validation rules. Step 3: Create an Input Message to Display (Optional)If we want to display a message to the user saying which type of data is supported or allowed in the selected cell, we can use the input message tab. Using the input message, we can inform the user regarding the allowed data type format when the user selects a corresponding cell/ cells. For example, we can display the following message into the desired fields (cell/cells/range). Once the input message is entered, we can click the OK button or move to the Error Alert tab further. After setting up an input message, the corresponding cell (s) displays the message like this: Step 4: Add an Error alert (Optional)In addition to an input message, we can also set an error alert to display when the user enters invalid data into the respective cells. Moreover, we can also add a custom error message. In the above image, we used the option 'Stop' as an error alert style. We can use the other two styles, Warning and Information, accordingly. Lastly, we must click the OK button. When the user enters invalid data, it triggers an error window with a message, and the invalid input is not allowed. If we don't set a custom error alert and set the validation rules ins Excel cell(s), Excel automatically displays the default error alert with the predefined error message. It looks like this: Data Validation ExamplesThe following are some essential examples of Data Validation in Excel: Example 1: Restricting users to enter/choose specified values from the drop-down menuSuppose we want to restrict users to select an option/ value from a list of predefined values. This case of data validation is used in most of the Excel sheets. In our example, we want to restrict users to select a gender from the predefined values, such as 'MALE', FEMALE' or 'OTHER'. For this, we need to perform the following steps:
That is how we can use the data validation feature in Excel and create drop-down lists. Example 2: Restricting users to enter valid Email IdSuppose we want to apply data validation in specific cells to restrict users to enter an email id with a valid format, i.e. username@domain, where the domain refers to an email service provider. For this, we need to perform the following steps:
That is how we can restrict specific cells in Excel to accept only the valid email id/ address. Similarly, we can type any other specific text to restrict the user inputs accordingly. However, it is important to note that the FIND function is case sensitive. So, if we don't need to restrict the case of the text, we can use the SEARCH function instead of the FIND function in the above process. Example 3: Restricting users from entering future datesEntering dates in an Excel sheet is one of the common data entry tasks. Sometimes, users may enter wrong dates or future dates, even when all the dates we want in a sheet are recorded earlier. In this case, we can use data validation to prevent future dates in a specific cell(s). For this, we need to perform the following steps:
Similarly, we can allow other restrictions for dates using the Data Validation feature in Excel. Example 4: Restricting users to enter values of the specified lengthSometimes, there may be cases when we want to restrict users to enter values of any particular length or characters. Suppose there is a need to accept PAN Numbers in cells entered by users. Since the PAN number is a ten-digit unique alphanumeric number, we can create validation rules to accept the values with length 10. For this, we need to perform the following steps:
Similarly, we can set other restrictions for length based values using the Data Validation feature in Excel. Example 5: Restricting users to enter values in Uppercase onlyIf we want to receive user inputs only in uppercase, we can set the validations in Excel. Suppose we want to accept the entry of a PAN number that contains both the text and numbers. However, we only want to take it in uppercase by the user. For this, we need to perform the following steps:
Similarly, we can set other restrictions with a custom formula using the Data Validation in Excel. How to edit Validation Rules in Excel?Suppose we have applied the data validation in an Excel sheet earlier and now edit the validation rules. We must perform the following steps to change or edit the validation rules:
How to locate or find Data Validation?Suppose we have an Excel sheet with the data validation rules applied to it. Now, we want to find out the cells with validation. We must perform the following steps to find cells with data validation in Excel:
After using the steps, the corresponding cells with the validation will be selected/ highlighted. How to copy Validation Rules to other cells?Suppose we have some cells with validation rules, and we want to apply the same validation rules on other cells. To do this, we can use Paste Special feature, as listed below:
This will apply the same validation on other cells on which the contents are copied. How to remove or clear Data Validation?There are two common methods used to remove or clear all the validation in Excel: Method 1: Clear Data Validation using the Data Validation Dialog Box
This will remove/ clear data validation from the selected cell(s). Method 2: Clear Data Validation using Paste Special Feature
This method typically replaces the data validation with the empty cells, which is an indirect way of removing data validation in Excel.
Next TopicApply data validation in Excel
|