In the world of dashboard and report generation every little trick can help.Â The trick might save you time, make something possible, or just look pretty sweet.Â I think that any one of these is a great reason to employ an Excel trick, but I have to be honest; I am partial to the last one.

The reason that I love Excel tricks that look sweet is that often times if it looks sweet then it is also more likely to be used and appreciated by others.Â On top of all of that it can be fun just seeing what Excel can do.Â With all of that in mind, I give you my first post on Excel Tips and Tricks: Creating a Dynamic Data Validation Range.

The first tool that you will need is the “INDIRECT” formula.Â The INDIRECT formula takes a text string and evaluates it as a range.Â So, whereas normally a formula might say ‘=sheet1!A6’ and INDIRECT would look like ‘=INDIRECT(“sheet1!A6”)’.Â The main difference is that the second formula is text and can be broken up into text segments and concanated together like this ‘=INDIRECT(“sheet1″&”!A”&6″)’ which is the key because then any component within the INDIRECT can be part text part cell references, calculations, formulas, etc.Â Here’s and example of that ‘=INDIRECT(“sheet1″&”!A”&3*2)’ or if cell B1 had a value of 6 in it ‘=INDIRECT(“sheet1″&”!A”&B1)’.Â All of these formulas would return the value that is in sheet1!A6.

Whew! Take a deep breath after that.Â Perhaps take a second to play around with it because the next part relies on it.

The difficult part about using data validation in a cell is that the data validation range must be in the same sheet as the cell you are validating.Â Unless you use a named range.Â You cand define a named range in 2 ways.Â The first is to select what you want and then in the box in the upper left corner of the sheet type a name.Â The second is to use Insert > Name > Define (2003) or Formulas > Defined Names > Define Name >Define Name (2007)

Here’s the setup.Â I am entering “List of Letters” in Sheet2!A1 with letters A – F in column A rows 2 – 7.Â Select Sheet2!A1:A7 and type “Data” into that box in the upper left corner.Â You should now have a named range called “Data”.

Then in cell Sheet1!A1 Use Data Validation and select List for the “Allow” drop box.Â For the source type “=Data”.Â You should now have a drop down in Sheet1!A1 that has all of the values from Sheet2!A1:A7.Â Now you have applied Data Validation to a cell that pulls from a list on a separate sheet.Â Nice.

Now for that extra piece of flare.Â We need to redefine this named range.Â For this go back into the Define Name – select the name and click edit; in 2007 use the “Name Manager”.

Now, we get to use the INDIRECT from before.Â We will start off nice and simple.Â While the current name should be defined as ‘=Sheet2!$A$1:$A$7’ we will just make that and INDIRECT so we get : ‘=INDIRECT(“Sheet2!$A$1:$A$7”)’.Â Now we want to change this so that we know how far down to go.Â Right now we go to A7, but what if things are added.Â We would have to redefine the name every time.Â Luckily, we can use the COUNTA formula to count the number of non-empty cells.Â In this case COUNTA(Sheet2!A:A) should equal 7 (one for the heading and one for each letter).

Lets throw that into our named range definition in place of the last “7” so that we get: ‘=INDIRECT(“Sheet2!$A$1:$A$”&COUNTA(Sheet2!$A:$A))’.Â Notice that we have to put in the quotation and ampersand right before the COUNTA because we are building a text string.Â As a final touch lets say that we don’t want the heading the drop-down box in Sheet1!A1.Â We have to change the row that the range starts on so we get : ‘=INDIRECT(“Sheet2!$A$2:$A$”&COUNTA(Sheet2!$A:$A))’.

As a final wrench, lets just say that the list on sheet2 is moved from A1:A7 to A:3:A9 with A1 and A2 blank.Â Here we would just have to add something to the formula on the end to pad it for the blank rows and change the starting row.Â In this case we would end up with ‘=INDIRECT(“Sheet2!$A$4:$A$”&COUNTA(Sheet2!$A:$A)+2)’

Let me know your thoughts on this post and if this worked for you!

This has been a Thought From The Cake Scraps.