Data Validation is a feature in Microsoft Excel which restricts the values or type of data that users enter into a cell. It automatically checks whether the value entered is allowed based on the specified criteria. This step by step tutorial will assist all levels of Excel users in allowing numbers only by using Data Validation
Figure 1. Final result: Data validation allow numbers only
Working formula: =ISNUMBER(C3)
Syntax of ISNUMBER Function
ISNUMBER function tests if a value refers to a number and returns TRUE; otherwise it returns FALSE
=ISNUMBER(value)
- value – the value that we want to test; value argument can be a blank or empty cell, error or logical value, text, date, number or a cell reference
Setting up Our Data
Our table consists of two columns: Student ID (column B) and Age (column C). We want to restrict the values entered in column C and allow numbers only. We can do this by using Data Validation.
Figure 2. Sample data for data validation to allow numbers only
Allow numbers only using Data Validation
We want to restrict the values to input in column C to numbers only. We can do this with Data Validation by following these steps:
Step 1. Select the cells whose values we want to restrict. In this case, select cells C3:C7
Step 2. Click the Data tab, then the Data Validation menu and select Data Validation
Figure 3. Selecting Data Validation
The Data Validation dialog box will pop up.
Figure 4. Data Validation preview
Step 3. Click the Allow: drop-down button and select Custom as Validation criteria
Step 4. Enter the following in the Formula bar: =ISNUMBER(C3)
ISNUMBER returns TRUE for numeric values and FALSE if otherwise. If the value entered in the cell is not a numeric value, Data Validation fails and the value is restricted.
Figure 5. Creating a Data Validation rule
Step 5. Click OK
We have now restricted the values in C3:C7 to allow numbers only through Data Validation. Let us try and enter “18” into cell C3.
Figure 6. Numeric value allowed by Data Validation
The value “18” is allowed because it is a numeric value. Now let’s input “twenty” into cell C4.
Figure 7. Non-numeric value restricted by Data Validation
The value “twenty” is not a number, hence Data Validation has restricted the input of “twenty” into cell C4. For restricted values, Excel shows a default warning message that says
“The value you entered is not valid. A user has restricted values that can be entered into this cell.”
We are then presented with three options: Retry, Cancel or seek Help.
Customize Error Alert in Data Validation
While using Data Validation, we can customize the error alert or warning message when an invalid value is entered. This way, we can help the user input the correct values by specifying the values that are allowed in the selected cells.
Let us follow these steps:
Step 1. Click the Data tab, then the Data Validation menu and select Data Validation.
Step 2. Click the Error Alert tab
Step 3. Enter the following in the Title bar: Numbers Only
Step 4. Enter the following in the Error Message bar: Please input numbers only!
Figure 8. Customizing error alert in Data Validation
Step 5. Click OK.
Let’s enter the value “twenty” again into cell C4.
Figure 9. Data Validation showing customized error alert
The value “twenty” is still restricted but this time, the error alert says “Please input numbers only!”. We are thus guided to enter only numbers into the selected cells.
See below table that is filled up with numbers as allowed by Data Validation.
Figure 10. Output: Data Validation allow numbers only
Most of the time, the problem you will need to solve will be more complex than a simple application of a formula or function. If you want to save hours of research and frustration, try our live Excelchat service! Our Excel Experts are available 24/7 to answer any Excel question you may have. We guarantee a connection within 30 seconds and a customized solution within 20 minutes.
Leave a Comment