You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
The Corporate Finance Institute Excel
Example 2
Let’s now understand how we can build a data validation rule for a date using
the function. Suppose we wish to create a rule that allows only a date within
the next 30 days, we can use data validation with a custom formula based on
the AND, and TODAY functions.
Suppose we are given the following data:
Different users of this file will input dates for B5, B6, and B7. We will apply data
validation to C5:C7. The formula to be applied would be:
If we try to input a date that is not within 30 days, we will get an error. Data
validation rules are triggered when a user tries to add or change a cell value.
The TODAY function returns today’s date. It will be recalculated on an ongoing
basis. The AND function takes multiple logical expressions and will return TRUE
only when all expressions return TRUE. In such case, we need to test two
conditions:
B3>TODAY() – It checks that the date input by a user is greater than today.
B3<=(TODAY()+30) – It checks that the input is less than today plus 30 days.
Excel stores dates as sequential serial numbers so they can be used in
calculations. By default, January 1, 1900 is serial number 1, and January 1, 2018
is serial number 43101 because it is 43,100 days after January 1, 1900. Hence,
we can simply add the number of days as +30 to the TODAY function.
If both logical expressions return TRUE, the AND function returns TRUE and the
data validation succeeds. If either expression returns FALSE, the validation fails.
corporatefinanceinstitute.com
51