Blog Archives

Excel – Creating Dependent Validation Drop Down Lists

In an earlier blog, I showed you how to create drop down lists and rules to control what people enter into your spreadsheets using DATA VALIDATION rules. These are a great tool to use and dramatically reduce the number of user input errors.

Going back to our timesheet example, we set up a number of drop down lists and rules, but there is still margin for error. For example, not every employee might work on every project and task combination. There are chargeable and non-chargeable activities but these are all in a single list. In both these examples, a user could correctly select their name (if they can’t do that then there is no hope!) or identify an activity as non-chargeable but select totally the wrong project/task combination or assign a chargeable activity. So although we have limited their choices, there is still lots of potential for messing things up.

To get around this problem we need to create linked or dependent validation drop down lists, where a choice made in one cell affects the choices available in the next.

To make this work, we need lots of NAMED RANGES.

Let’s take the chargeable/non-chargeable options as an example.

At the moment our drop down list in the Details column is using the named range Reasons but this contains every option – both chargeable and non-chargeable. First we need to split this into two separate lists – chargeable reasons and non-chargeable reasons.

ScreenHunter_111 Aug. 19 13.00

Now, we need to name our two lists. When you name them you MUST use the values from the drop down list that will determine the options in list 2. In this example, the options in the first drop down are “Chargeable” and “Non-Chargeable”. Our two lists must therefore use those names for the linking to work.

Highlight the cells containing the chargeable items and then click into the NAME BOX and type in Chargeable. Repeat for the Non-Chargeable items. At this point however, you may get an error message.

ScreenHunter_111 Aug. 19 13.13

Remember that when naming ranges you cannot have spaces or certain characters including dash (-) which we have here. This means we have to adjust our values in the first drop down to remove any spaces or dashes etc. If you don’t do this then you can’t link the two validation lists. Mildly irritating, but necessary.

In this example I will opt for an underscore to give us a value and matching named range of Non_Chargeable.

Once you have all your named ranges, all that’s required is to make it work!

Go back to the Timesheet and edit the existing validation rule in the Details column. Instead of referring to the full list of options stored in the named range “Reasons” we enter a formula…

=INDIRECT(D5)

ScreenHunter_111 Aug. 19 13.33

Column D contains our drop down with the Chargeable/Non_Chargeable options. What the INDIRECT function does is look in cell D5 and then goes to find whatever it finds in that cell. In this instance, the only things called “Chargeable” or “Non_Chargeable” are named ranges. The values that make up the named range are then displayed in the drop down list.

So now when you make a choice in column D it determines what appears in column E.

ScreenHunter_111 Aug. 19 14.07

Or if you select Non_Chargeable…

ScreenHunter_112 Aug. 19 14.08

This has now added a new level of control to the worksheet, preventing users from making an incorrect selection following a selection in another column.

This method can be continued by creating new named ranges using the values from the named ranges we just created. Let’s say that after choosing “Chargeable” as my first option, I am then given the limited list of options that are chargeable. From that list I choose “Training”. Assuming we have another column, I would want a list of training courses to appear so that I can select from that list. Similar to what I did above, I would create a list of training courses and name it “Training” – an exact match for the value in my details drop down list. Repeat this process for each and every option in your drop down list. You could end up with dozens of named ranges but at least you will know that what you get back from users will be correct.

Advertisements

Excel – Using Data Validation to Control Data Entry

They say that two things in life are unavoidable – tax and death. There is, however, one more you can add to the list, and that is people mucking up your spreadsheets! Send out a spreadsheet to five different people and you can guarantee you will get at least one person filling it out in some strange and obscure manner, and some bright spark won’t like your layout so they decide to re-arrange your table to suit them.

So how do you stop all of that? There are two basic things you can do:

  • Apply DATA VALIDATION to your tables
  • Apply varying degrees of PROTECTION to your worksheets and workbooks

Here, I am going to tackle DATA VALIDATION.

DATA VALIDATION allows you create drop down lists in cells as well as create rules that control what people can and cannot enter into a cell.

Let’s take a timesheet as an example…

Each week I want team members to fill out their own timesheet. They need to fill out all times for one week starting on a Monday through to Friday. Work is done on projects, and more specifically to tasks within a project. Time can be chargeable or non-chargeable to the project and different activities will fall into each of those categories. Team members are also required to add a justification where necessary, such as overtime. And finally, the timesheet needs to be approved by the manager.

So with all the different bits of information required, the possibilities for errors and creative form filling are endless.

A lot of this timesheet relies on specific project numbers and category descriptions. This sort of data entry is prone to errors, so use DATA VALIDATION to create drop down lists forcing users to select from a specific list of options, with no allowance for users to add their own values.

First, let’s create a list of team members so people can’t even get that wrong! Create a list (ideally on another sheet in the workbook – makes hiding the lists easier afterwards).  If you want, name your list e.g Team. This is not strictly necessary if you are using Excel 2010/2013 but makes life easier and is a MUST if using 2007 or earlier if your lists are on a separate sheet from the sheet where the drop downs will be used as you cannot select cells on another sheet unless they are part of a named range.

In your timesheet, click on the cell(s) that will have the drop down list. Assuming we have already created a list, go to the DATA tab and select DATA VALIDATION.

From the ALLOW options, select LIST.

In the SOURCE box use the range picker button to select the cells containing the list values, or if you have created a named range type = followed by the range name i.e. =Team (note: no speech marks).

ScreenHunter_109 May. 15 14.49

You should now have a fully working drop down list to choose from.

ScreenHunter_109 May. 15 15.00

To help your team use the drop down properly, you can add an optional prompt. Go to the INPUT MESSAGE tab, add a title of some sort and a useful message to assist (rather than confuse) the users.

ScreenHunter_109 May. 15 15.03

Click on OK to confirm. You should now see this next your cell.

ScreenHunter_109 May. 15 16.01

You also have the option to control whether people are restricted to using only the values in the list, or whether they can type in their own values. The latter option is potentially dangerous, but this may be necessary so a good user prompt here is a plus.

Go to the ERROR ALERT tab.

Under STYLE, you have 3 options;

  1. Stop – limits values to those in the drop down list ONLY (Good choice!)
  2. Warning – warns you are about to enter a value that is not in the list and asks if you wish to continue. To which you can say ‘yes’, therefore ignoring the list completely.
  3. Information – even less harsh than Warning. Tells you the value you are entering is not in the list. Click on OK to ignore and continue regardless.

There may well be times when you do want to give people the option to enter other values, which is fine, but if you want to cut out any form of creativity with your spreadsheet go for STOP!

If you don’t want the standard pop up message from Excel, type in your own title and message, so if someone enters something outside the list they get a custom message;

ScreenHunter_109 May. 15 16.19

Continue to apply drop down lists with input and error messages where appropriate.

DATA VALIDATION though is not limited to just creating lists. Create rules to control any of the following:

  • Whole numbers
  • Decimals
  • Dates
  • Times
  • Text length
  • Custom (create your own rules using formulas)

In each case you will have a variety of options: between, greater than, less than etc. Pick an option and enter values to suit your rules.

ScreenHunter_109 May. 17 15.19

Most of the options are self-explanatory but CUSTOM is where you can create formulas to create complex rules that may involve multiple cells. When using the CUSTOM function just be careful with your relative and absolute cell references especially when applying your validation rules to a block of cells. Although you apply the rule to a range of cells you are actually writing the formula for the first cell in the selected range and Excel copies the formula down/across to the other cells.

Eventually, you will get a complete timesheet looking something like this…

ScreenHunter_110 Jun. 04 16.40

So that is DATA VALIDATION. We now have a working spreadsheet where users have limited options on how to fill it out. However, there are still a number of issues that need to be dealt with here to further improve the reliability of the timesheet;

  • Incorrect project/task combinations
  • Incorrect status/details combinations
  • Late submission of the timesheet
  • Authorisation access

I will cover these in “Creating Linked Validation Drop Down Lists” and “Protecting Your Workbooks”. Further enhancements could be added using VBA…so by no means a done deal yet!

Also see “Data Validation Error Checking & other useful tips”