Академический Документы
Профессиональный Документы
Культура Документы
http://www.accountingweb.com/article/automating-data-validation-lists...
Home
Tax
A&A
Tech
Practice
Careers
Blogs
Resources
Videos
States
AWEBLive!
Partners
www.siftmedia.co.uk - Interactive community publishing Registered in England & Wales No. 05923499 Terms & conditions | Privacy
Let's first take a look at the Data Validation feature. On the first worksheet of the workbook where you created your list, click on cell A1 and type the word Fruit. Next, select cell A2 and choose Data and then Data Validation. The dialog box in Figure 3 will appear. On the Settings tab, choose List in the Allow field. When the Source field appears, type an equal sign along with the range name that you assigned before, such as =Fruit.
Figure 3: Choose List and then specify your range name as the Source on the Settings Tab. On the Input Message tab, enter a title, such as the word Fruit, to describe the input field, along with a message, such as "Choose an item from the list," as shown in Figure 4. It's not necessary to use quotation marks in the Description field.
This material focuses on non-profit organizations organization, accounting and reporting. Mar 26
Advertise on AccountingWEB
Figure 4: Although optional, the Input Message tab allows you to document the validation. Finally, on the Error Alert tab, enter a Title, such as "Invalid Input," and an Error Message, such as "You must make a selection from the list," as shown in Figure 5. Keep the style set as Stop to prevent the user from bypassing the list items. Click OK to close the Data
1 of 5
12-Mar-14 3:33 PM
http://www.accountingweb.com/article/automating-data-validation-lists...
Figure 5: Be sure to complete the Error Alert tab; otherwise, invalid inputs will trigger a generic and cryptic error prompt. Going forward, when you click in cell A2, a note should appear as shown in Figure 6. This documents the spreadsheet. If the user makes a valid choice, he or she will then be able to move to another cell; otherwise, the prompt shown in Figure 7 will stop the user in his or her tracks.
Figure 6: Our choices on the Input tab yield a helpful prompt when the user clicks on cell A2.
Figure 7: The user will see this prompt if he or she tries to enter something that doesn't appear on the list. Now, return to your original list, and add two more items, as shown in Figure 8. When you return to your cell with the Data Validation list, the new items should appear automatically. The combination of the table/list features and range names automates this aspect. Within the Data Validation dialog box, you can provide a specific set of cell coordinates in the Source field, but you would then need to manually change the setting if you later expanded the list. Further, Excel 2007 and earlier won't allow you to reference cell coordinates on other worksheets. Best practices in spreadsheet design call for separating supporting lists from the actual data on separate worksheets. Anyone using Excel 2007 and later is no longer faced with the struggle of where to safely position supporting lists for Data Validation on the same worksheet as the actual input is occurring.
2 of 5
12-Mar-14 3:33 PM
http://www.accountingweb.com/article/automating-data-validation-lists...
Figure 8: Since the ultimate source for a validation list is a table/list, new items appear on the Data Validation list automatically. Read more articles by David Ringstrom. About the author: David H. Ringstrom, CPA heads up Accounting Advisors, Inc., an Atlanta-based software and database consulting firm providing training and consulting services nationwide. Contact David at david@acctadv.com or follow him on Twitter. David speaks at conferences about Microsoft Excel, and presents webcasts for several CPE providers, including AccountingWEB partner CPE Link. first previous 1 2
Here Are Some Risks to Consider Before Using Social Media for Your Business
Read more from Michael Alter here and in the Dollars and Sense archive. The noise about using social media as a means to grow your business has become so constant it almost blends into the background at this point. With...
3 of 5
12-Mar-14 3:33 PM
http://www.accountingweb.com/article/automating-data-validation-lists...
16 Comments
Jacky Choo
I have a list of categories which some of them contains white spaces, for example, Green Fruit - Apple, Grapes, and so on and some of the category start with number, I can't use them as the Name because the name distriction, need serious help on this~
David Ringstrom
You'll have to be inventive and use underscores "_" instead of spaces in your range names. Preface the ones that being with numbers with a \. You can then use the SUBSTITUTE function to replace the _ and \ characters as needed. You might also have to use the INDIRECT function as well. A great message board to post your question to is www.mrexcel.com if the aforementioned doesn't give you enough to work with.
Welshgasman
Just like to say 'Thank you' for this article. I was trying to use ranges and was planning on using dynamic ranges as the validation criteria, but excel 2007 in work would not allow it. Absolute cell references were find as the validation was on another sheet.
David Ringstrom
I appreciate your feedback. Dynamic ranges are a viable solution as well, but it's hard for the uninitiated to wrap their brain around.
CanIHasDropdowns?
David I'm building spreadsheets from a VBA macro in another app. I would like to build a sheet with my list values and hide the page, but I can't seem to add the drop-down menus on the user page. I can record a macro that creates the list and drop-down menu, but I can't seem to translate that to the original VBA macro I'm building. This code will create a new sheet, build a list and name it. (Note only the last five values are included in the list.)
Excel_App.ActiveWorkbook.Worksheets.Add Set HiddenValuesSheet = Excel_App.ActiveWorkbook.Worksheets(1) With HiddenValuesSheet .Name = "menus" .Visible = False .Cells(1, 1).Value = "Status" .Cells(2, 1).Value = "Completed" .Cells(3, 1).Value = "Draft"
David Ringstrom
You didn't say which version of Excel you're using, but in Excel 2007 and earlier your lists can't reside on another sheet. Also, your line of code .Name="All Data" is likely causing an error because range names cannot have spaces in them. I'd consider eliminating the hidden list and embedding it into your Data Validation code. Also notice that you didn't call Data Validation itself, so the line that starts with .Cells(2,2).Add is invalid, and should be .Cells(2,2).Validation.Add:
4 of 5
12-Mar-14 3:33 PM
http://www.accountingweb.com/article/automating-data-validation-lists...
5 of 5
12-Mar-14 3:33 PM