Limit Date Range with Excel Data Validation

Yesterday, one of my clients emailed to let me know that she was having trouble entering January dates in a file that I had created.

My first guess was that there was an issue with the regional settings, because her company uses the dd/mm/yyyy format.

But when I tried entering a January date, with my mm/dd/yyyy settings, I got an “Invalid date” message too.

datavaldates02

Limit Dates with Data Validation

The date that I had entered – 1/3/13 – was a valid date and in a valid format, so I checked the data validation settings. And that’s where I found the problem.

The cell had been restricted to dates from 60 days prior to the current date:

=TODAY()-60

and up to 60 days after the current date:

=TODAY()+60

datavaldates01

Fix the Problem

Those date range settings had made sense when we set up the file. The date range limits prevented people from accidentally entering strange dates, such as mistyping a year – 2031 instead of 2013, for example.

Do you ever find records like that in your database or workbook? It can really mess things up!

Anyway, a simple change to the data validation formula fixed the problem. Instead of 60 days, I changed the formulas to 120 days.

=TODAY()-120

and

=TODAY()+120

It still prevents those year typos, but gives my client a bigger window for entering data in the file.

Video: Prevent Invalid Dates

In this video, three different data validation methods are used to validate dates. From the Allow drop down in the data validation settings, the following options will be used:

  • Specify a starting date and an ending date. (Date option)
  • Show a drop down list of valid dates (List option)
  • Create a rule in a custom formula (Custom option)

Video Timeline:

  • 0:00 Drop Down List of Dates
  • 3:04 Set a Date Range
  • 5:43 Check the Year
  • 6:55 Get the Sample File

More Data Validation for Dates

For more examples of data validation for dates, you can visit the Excel Data Validation – Dates page on my Contextures website.

_____________

Create Amazon Affiliate Links in Excel

This week, Dick Kusleika posted his Amazon Linkerator – an Excel file lets you create links to Amazon products.

First, you find a product on Amazon, and copy its web page URL. Then, open the form, enter a product code and description, and it creates a link for you.

linkerator1

It’s very fancy, and you can download the sample file, to try it for yourself. It uses an Excel UserForm, and you can modify the code to add your own information.

Jimmy Pena has an Amazon Link Builder too, and you can see the details here: Amazon Link Builder

Low Tech Amazon Link Builder

I build Amazon links too, and you can see lots of them on my Excel Book List page.

To create my links, I use worksheet formulas, instead of a fancy UserForm. If you like things simple, you can try this method.

You enter the product code and product title, and then copy the link or the HTML code, and paste it into your blog post or web page.

WARNING: Check the latest information on the Amazon website, to be sure that these short links are still permitted. Their policies can change at any time.

amazonlink01

How It Works

First, a link is created in cell B5, from the Amazon URL, the product code (ASIN) and the Tracking ID.

=https://amzn.com/ & ProdCode & “?tag=” &TrackID

Note: Cell B3 is formatted as Text, because some codes start with a zero, and you don’t want Excel to remove those.

amazonlink02

Then, that link is used in the to create the HTML code in cell B7.

The four HTML cells have snippets of text that are required for building the HTML code. The formula in cell B7 combines the product title and the link, with four snippets of text.

=HTML_01 & ProdTitle & HTML_02 & ProdLink
& HTML_03 & ProdTitle & HTML_04

Download the Sample File

To test the Amazon link formulas, you can download my sample file, from the Excel Sample Files page on my Contextures website. In the Functions section, look for FN0025 – Build Amazon Affiliate Links

____________________

Validate Entries in Excel Combo Box

One of my Excel sample files lets you double-click on a cell that has a data validation list, and a combo box pops up. The combo box has advantages, because you can set the font size, and the number of rows in the drop down list, and the entry autocompletes as you type.

Continue reading “Validate Entries in Excel Combo Box”

Excel UserForm with Dependent Combo Boxes

In an Excel UserForm, you can add combo boxes to make data entry easier.

The UserForm in this example is used to enter parts information onto a hidden inventory sheet.

Before selecting a Part ID, you have to select a Part Type. When the Part Type combo box is updated, code runs, and creates a list of parts, for the selected part type.

Excel Parts Inventory UserForm with Dependent Combo Box
Parts Inventory UserForm with Dependent Combo Box

How It Works

In the background, an Advanced Filter runs, to create a worksheet list of parts for the selected part type.

That list is set up as a named range, and the range name is used as the Part ID combo box row source.

Watch the Video

To see how the dependent combo boxes work, watch this short video.

Video Timeline

  • 0:00 UserForm Demo
  • 0:53 Lookup Lists Sheet
  • 1:25 See How Macro Works
  • 1:48 Named Range for Parts List
  • 2:02 UserForm Macro Code

Download the Sample File

To test the dependent combo boxes on the UserForm, and to see the code, go to my Contextures website, and download the sample file.

_______________