Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Setting date limitation formulas

From: Excel 2010: Data Validation in Depth

Video: Setting date limitation formulas

In this worksheet, data validation rules in columns C require that all the dates occur in the year 2011. Column D doesn't have any rules yet, but in putting in the shipping dates for the items that have been ordered, we are going to make sure, first of all, that the shipping date is later than the order date. Now depending upon the environment of course, you might want to set up a rule to make sure that the shipping date is equal to or greater than the order date. But what if in this environment that the items being ordered require some assembly and packaging, and shipping cannot occur within a two-day time frame? In other words, it has to be more than two days later.

Setting date limitation formulas

In this worksheet, data validation rules in columns C require that all the dates occur in the year 2011. Column D doesn't have any rules yet, but in putting in the shipping dates for the items that have been ordered, we are going to make sure, first of all, that the shipping date is later than the order date. Now depending upon the environment of course, you might want to set up a rule to make sure that the shipping date is equal to or greater than the order date. But what if in this environment that the items being ordered require some assembly and packaging, and shipping cannot occur within a two-day time frame? In other words, it has to be more than two days later.

We want to make sure that the entries in column D are more than two days later. In this case, maybe we don't want to restrict these to the year 2011 because toward the end of the year some of the items might be shipped in the later year. So clicking column D here and setting up data validation, the first thought might be, as you look at the dialog box, that the validation criteria we are trying to set up here involves using probably a Date criterion, but it is not; it is going to be Custom-- actually a custom formula.

And the formula will involve using the active cell. Now, I did select column D, and I highlighted cells starting in D2. We probably see D2 as the active cell. See, in the upper-left corner here, to the left of the Formula bar, but we are seeing D1 right now, so we will use this in the formula. The formula here is not so obvious, but once you see it, it will start to make some sense. = D1>C1+2. Now although literally we don't see the meaning here, what this means is any entry in column D must be more than two days greater than the entry in column C. And so even though we are not using D1 and C1, the formula involves those two cells.

So when we click OK here, sometimes it is a little startling at first when you see this message, and it simply means the D1 and C1 don't fit our little formula. Do we want to continue? Yes, we do. So, simple test here. How about the 5th, 1/5/11, the 5th of January? Why is that wrong? Our formula indicates the shipping date must be more than 2 days, not 2 days, but more than 2 days later. We will do a retry and we will make this 6, for example. How's that looking? Fine, so we can put in any date here that's more than two days later than the order date.

For every single cell here, the comparison is made with the cell to its left. Now what if we are making adjustments here and we put in a different date? I am going to put in an 8 here for the shipping date. Then this thought might occur to you: what if one of the dates that you put in here is a Sunday? Maybe you don't do shipping on Sundays. Is that a Sunday? Or maybe don't do shipping on Saturdays. Let's also screen out those kinds of entries as well. Now, you may or may not be familiar with this function, =weekday, an Excel function.

And in looking at a date, it will tell us the day of the week--not initially in a very meaningful way. It gives us a value. 7 does mean Saturday. 1 means Sunday and so on. So if we don't want entries for the weekday is equal to 7 or 1, that would be Saturday or Sunday, we can screen out those as well. So what I would like to do here is prepare this formula outside of, although you can certainly do it with inside, data validation. Let me just copy it in. So I would like to use this function here along with the current restriction that the shipping date being more than two days greater than the order date, and so the function will read something like this. And, meaning we have got two criteria we want to set up here.

The first one we already wrote, but I will write it again, and D1. Don't really have to capitalize, but it is easier to see this way. D1>C1+2, and weekday of D1<>1, meaning Sunday, and another one of these. And I will just copy this and paste it and change it slightly. Ctrl+C here, click right here, Ctrl+V, 7. Now the formula is not going to stay into this cell.

I am just typing it here so you can see it more clearly. And here's the formula that we are about to use as a validation formula. And in English, it reads as follows. In column D, every entry must be more than two days larger than the corresponding entry in column C, and the weekday of the entry in column D cannot be equal to 1--that's Sunday; can't be a Sunday--and it cannot be equal to 7, which is Saturday. So all of this here is going to be the validation formula.

You don't necessarily need to prepare it this way. You can do this within the data validation dialog boxes, which is what we are about to do. But here all I am doing is highlighting this and copying with Ctrl+C, and I might want to leave it here for a moment for documentation, so I will just put in a space and press Enter. Go back to Data Validation. Click column D > Data Validation, and instead of this rule, I'm simply going to press Ctrl+V here to paste in the formula that I just had displayed earlier.

Sometimes when you look at these, they are a little clipped off. I am going to drag leftwards so we can see it all. It looks a little funny at times. So there is that same formula, which all this could have been prepared within here. Click OK. Now the existing date that's there will not change. Data validation doesn't do anything with existing data; it is the new data that it is going to react to. Once again, we get this kind of a message, simply meaning that cells D1 and C1 don't fit our rules. We do want to continue anyway. So as an example here, I'll try and change this to the 9th.

That's a Sunday. And we see that it doesn't work. Now ideally, what we should do here to accompany all this--and that was shown in previous movies--going back to Data Validation, provide either an input message that describes the dates cannot be Saturdays and Sundays, or possibly and create an error alert message that explains why an entry is incorrect. You don't necessarily need to do those, but it's helpful to explain to some people what went wrong. So on a different entry here and I'll just type in a date here, 1/8/11.

That's a Saturday and we get the same message. And of course a correct entry here looks like 7 is going to work there. Here we go. That's a Friday. That's just fine. So you get the idea. The more you know about Excel functions, the more inclined you are likely be to use more sophisticated approaches to controlling data. So column D from now on has entries that have to meet all three of the criteria that we set up in this data validation formula.

Show transcript

This video is part of

Image for Excel 2010: Data Validation in Depth
Excel 2010: Data Validation in Depth

17 video lessons · 9208 viewers

Dennis Taylor
Author

 

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now "Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Excel 2010: Data Validation in Depth.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.