Excel 2007 Named Ranges and Data Validation
It’s hard to find information on Excel Named Ranges for Excel 2007 using a search engine. The problem isn’t that there’s no information available, but rather that most of it refers to older versions of Excel. And of course, that would be fine, if Excel 2007 didn’t go and move everything around and add that darned Ribbon thing to make it impossible to find anything. But I digress.
Today I’m working on something in Excel and I want to be able to limit the available values the user can enter into a cell. Should be pretty easy, but I’m having a hard time finding how to do it and it’s been like 5 years since I had to do this so I’m searching for help. Of course, I’m probably not searching for the right terms when I say something like “limit column values excel” and get back a bunch of junk related to the maximum number of columns excel supports.
Once I remembered that these things are called Named Ranges I started to make some progress. What I basically wanted to do was let the user either type in or specify from a drop down list the values that were valid for the cell. It turns out that this is pretty easy to do by specifying a Named Range as the source of a List in the Data Validation. There are a few related tasks here, so let’s cover them one by one.
- Define a Named Range
- Limit Valid Entries In a Cell to a List of Values
- Delete and Manage Named Ranges
Defining a Named Range in Excel 2007
This is actually very easy, and allows you to later refer to the range by name rather than using its $A2:A17 nomenclature. For example, let’s say that you want to limit the Company Names listed in an Excel file to a particular collection of names (e.g. your customers). First, you probably want to put this list into a separate worksheet (which I’ll call Lookup) under a heading that describes the range. The following diagram shows an example:
In this screenshot, I’ve highlighted the Customer Names as well as the actual rows of data, but be careful not to do this when you’re defining your Named Range (go ahead, ask me how I know not to do this… or go ahead and do it and you’ll understand why the third part of this post is on deleting named ranges).
So, highlight just the values you want in your named range. Then click on the white space just above the A column (where it says B2 in my screenshot above). This is called the Name Box. Type in the name for your range. It has to be just one word, no spaces. Let’s call mine CustomerNames, as shown below:
You’ve just defined a Named Range in Excel 2007.
Limit Valid Entries In a Cell to a List of Values
Now switch to your main worksheet (using the tabs at the bottom of the Workbook) which might look like this:
Note that in this example I’ve been entering in customer names by hand, with some duplication. If later on I decide to change Contoso to Contoso, Inc. and then I want to run some reports or show a pie chart displaying sales by customer, these will no longer be grouped together. It’s much better to use a named range to define the list of possible values (and of course this might ultimately come from a database or web service) than to have a lot of manually entered data that could be slightly off.
In Excel 2007, if you want to limit the values a particular cell can have, you should click on the cell (or range) and select the Data tab in the ribbon. Then click on the Data Validation button, which will bring up the dialog shown here:
By default, cells can contain any value (no validation). In this case, we want to change this to use a list of values, so in the Allow drop down list, choose List. Then in the Source: field, put in ‘=CompanyNames’ replacing ‘CompanyNames’ with the name of your Named Range. Click OK.
You can apply the Data Filter to the whole column – it will ignore any headers that currently don’t match (though you’ll be able to use the dropdown on these as well later should you wish to, or simply remove the validation from the header row manually afterward). Now to add a new row, you can click on the dropdown arrow or start typing and get autocompletion of the data, like so:
Delete and Manage Named Ranges
Now let’s say you accidentally create a Named Range that contains more cells than you would like, or that isn’t named what you’d like. You might think that you could redefine that range by highlighting a selection of cells and retyping that name into the Name Box. But no, that doesn’t work. Fortunately, there’s a very easy way in Excel 2007 to manage all of your Named Ranges once you know where to look for it (and no, it’s nowhere in the Data Validation section where thus far we’ve been working with Named Ranges). The trick is to go to the Formula tab on the Ribbon (because frequently Named Ranges are used in Formulas, I suppose). There you will find a Defined Names section which includes a Name Manager. The Name Manager, as you might guess, makes it quite easy to add, edit, and delete Named Ranges from within Excel 2007.
Summary
Named Ranges are a handy feature in Excel. Finding out how to work with them in Excel 2007 if you’re familiar with Excel 2003 or earlier can be a challenge. With any luck, this post will help a few folks out or at least serve to remind me how to do this the next time I need to remember it.




Comments
Peter Wallace said on 23 Jun 2009 at 6:17 PM
I absolutely hate what Microsoft have done with Office 2007 and the ribbon. I find it almost impossible to use and I'm planning on going back to Office 2003. Vista is just as hopeless. Micorsoft are possessed.
fraz said on 02 Jul 2009 at 10:37 PM
I dont know why people always bitch about Excel 2007, you simply go into "Data" tab of the Ribbon obviously cuz ure validating the "Data" and its there Data Validation.
ive been working in excel 2003 for only 1 year and it took me 5 secs to figure out in Excel 2007 where Data validation would be. My suggestion stop vinging and use ur BRAIN!
Terri Morton said on 24 Jul 2009 at 2:58 AM
This is great Steve, thanks! I needed to do this in a spreadsheet tonight and found your blog post via Google. Pleasantly surprised to see that you are the author. :-)
Shravan said on 01 Sep 2009 at 4:18 PM
Hi Steve, thank you so much. This really helped me a lot. I was struggling to manage name ranges. Thanks again.
Bob Langley said on 02 Sep 2009 at 9:14 AM
Hi Steve
I've set up validation from a list using a named range and then use VLOOKUP to find references to what has been selected - that's all it does. Whenever the workbook is opened it has the last selection still visible in the validated cell rather than what I want. Can I set a default value for the validated cell?
Bob Langley said on 02 Sep 2009 at 9:45 AM
Hello again Steve
one solution to my problem of a default value is to make the file read-only so that it always loads with the cell displaying my chosen default. Although that works in this particular (unusual) case, it would be interesting to know about setting a default for a validated cell - from other searches it looks like some coding is required.
Mike B said on 10 Sep 2009 at 11:53 AM
Hi Steve -
Thank You for your efforts - I do understand all of the procedures for creating a named list and accessing the list within a worksheet or multiple sheets within an overall worksheet. My problem is that I want my validation data on a separate worksheet and am unable to reference the external worksheet in the "source" field of the data validation dialog box. What I guess I really need is the actual text required to define the external worksheet and the named range.
Please HELP !!!
Mike B
Paul said on 20 Oct 2009 at 1:00 PM
Cheers, Good article
Vroom said on 13 Nov 2009 at 10:35 AM
I had to make a change in named range that was absolutly time critical. Spent 15 mins banging my head in Excel 2007. No Luck. Spent 10 secs to search in google and 1 min to read your article. Job Done. Thanks a lot Steve!!! I owe you this one. :) Microsoft are hopeless. Can't they finalize on a Menu structure. Why do they bitch around with Menus and their names in every release.
Dave W said on 16 Nov 2009 at 8:49 PM
Thanks for this. A simple task made much more time consuming than it need be, courtesy of Microsnot...
Jim said on 04 Dec 2009 at 10:28 AM
Thanks soooooo much. Gotta love Microsoft's lack of intuitiveness.
hunter said on 10 Dec 2009 at 1:46 PM
Thank you so much for this blog - yours was the only place i could easily find this info.
Stavros Michael said on 16 Dec 2009 at 4:21 AM
In my case after setting the source for data validation equals to the defined name range it gives me an error: "The formula you typed contains an error". Any ideas on this? Thanks
Stavros Michael said on 16 Dec 2009 at 4:21 AM
In my case after setting the source for data validation equals to the defined name range it gives me an error: "The formula you typed contains an error". Any ideas on this? Thanks
Stavros Michael said on 16 Dec 2009 at 4:21 AM
In my case after setting the source for data validation equals to the defined name range it gives me an error: "The formula you typed contains an error". Any ideas on this? Thanks
Grafica said on 01 Jan 2010 at 10:35 PM
If I delete a named range which is being used in a formula the formula will return #NAME? And I cannot undo the deletion od a named range using (Edit > Undo). Also, If I delete rows and columns that contain named cells or ranges then the named ranges will become invalid. The cell references used by the named ranges will then contain #REF!.
Is there any way to solve this problem if I deleted the contents of a cell?
Thanks.
Paul said on 12 Jan 2010 at 12:20 PM
Thanks for the info but how do I make Excel see updates to the named range? Even when I attempt to create a new named range for the same data it references the existing named range which won't update.
I would like to thank MS for making my life soooo much easier with this "feature". The crappy software apparently knows better than me what I need to accomplish.
Heidi said on 04 Feb 2010 at 8:16 PM
Thanks Steve. Naming the range is easy, but I had no idea where to look to Manage the names and MS help was not helpful. Not sure why they thought that it was a good place to put it in the Formula ribbon! Your blog was v.helpful. Thanks
mok said on 05 Feb 2010 at 1:52 AM
I found a useful Excel tool recently.
It can easy to find your excel files in seconds.And then split multi-sheet excel files into single sheet excel files with high speed.
It do help me a lot.
So, I want to share it to you:
http://www.excelpedia.com
Jerry Nixon said on 18 Feb 2010 at 11:55 PM
Thanks, Mate.
kitz said on 23 Mar 2010 at 6:58 AM
this was very helpful. solved my problem in less than a minute! thanks!
matt said on 14 Apr 2010 at 4:36 PM
thanks alot. could not figure out how to edit or delete these lists. as my data expanded i always had to create a new bigger list. :( thanks again.
Olga Stefansdottir said on 20 Apr 2010 at 9:38 AM
Thank you for this. I just have a question regarding the autocompletion, you say:
"Now to add a new row, you can click on the dropdown arrow or start typing and get autocompletion of the data"
I can't get the autocompletion to work, i.e. I have to select the value from the list. How can I get it to autocomplete, i.e. type in "North" and get to "Northwind" in the list?
many thanks!
Olga
Cartão de Visita said on 19 Jun 2010 at 7:56 PM
Nice blog. Thanks.