Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
The Corporate Finance Institute Excel
Example 1
Let’s assume we shared an Excel file with several users. We want to ensure that
a user enters only dates in a certain year. In such a scenario, we can use data
validation with a custom formula based on the YEAR function.
Suppose we are given the following data:
Using the data below, we want that user needs to enter only dates in B4 and
B5. For this, we will set a data validation rule as follows:
Data validation rules will be triggered when any user tries to add or change the
cell value.
When the years match, the expression returns TRUE and the validation
succeeds. If the years don’t match, or if the YEAR function is not able to extract
a year, the validation will fail.
The custom validation formula will simply check the year of any date against a
hard-coded year value using the YEAR function and return an error if the year
is not entered. If we want that a user enters only a date in the current year
then the formula to be used is =YEAR(C5)=YEAR(TODAY()).
The TODAY function will return the current date on an ongoing basis, so the
formula returns TRUE only when a date is in the current year.
corporatefinanceinstitute.com
53