98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Dynamic drop down
Dynamic drop down
Resolved · Low Priority · Version 2007
Susanna has attended:
Excel VBA Intro Intermediate course
Taking Minutes course
Excel VBA Advanced course
Excel PowerPivot course
Dynamic drop down
The required functionality is:
you select a fruit item in column A, then move on the same row into column B where the data validation (drop-down list) shall now show the sub-selection of the selected item in col.A.
In the following sample I tried a very simplistic UDF which should return the row of the active cell. Just for testing purposes I refer to it in cell E10, ultimately this should go into the range name "Sorts_List". It does it occasionally - don't know why it works sometimes.
In the example I show an alternative approach which is not totally satisfactory either.
I would like you could please check the UDF in Module 2 and advise how to make it work.
Is there any way I can send you the excel file?
Thanks a lot,
Susanna
RE: Dynamic drop down
Hi Susanna
Thanks for getting in touch. If you can send it through to gary@stl-training.co.uk I will take a look at it for you.
You can also achieve the same thing without VBA using a process known as "conditional drop-down":
http://blogs.office.com/2009/11/24/create-conditional-drop-down-lists/
Kind regards
Gary Fenn
Microsoft Office Specialist Trainer
Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us
London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector
RE: Dynamic drop down
Hi Gary,
The solution proposed by you is pretty much hard-coded because you have to define specific names for the sub-groups.
With my UDF my intention was to make it totally flexible. So I would still would be very interested in understanding how my 1-line VBA can be made to work.
I have sent you the xls file by mail.
Thanks,
Susanna
RE: Dynamic drop down
Hi Susanna
Thanks for your reply. Functions are not well-suited for handling ranges. It's possible with functions like Application.Caller but it's not optimum. Hence your function will often give up
Rather than reinvent the wheel there are many suggestions online for how you can build these dynamic dependant drop-down lists, depending on your scenario.
Many options are discussed here:
http://stackoverflow.com/questions/14996838/multiple-dependent-dropdown-lists-in-excel
In particular the answer here is closest to your needs:
http://stackoverflow.com/a/14997530
I hope this helps.
Kind regards
Gary Fenn
Microsoft Office Specialist Trainer
Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us
London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector
RE: Dynamic drop down
Hi again,
I've got it (with the help from Jeremy)
Use a worksheet function for "SelectionChange" (code in worksheet rather than a module)
worksheet function puts current row into a named range (Curr_Row)
Define Curr_Row on the worksheet.
Only cosmetic blemish is that this Curr_Row range must reside somewhere on the sheet where the dynamic drop-downs are used. (I'd have preferred to move it into a hidden Parameters sheet.)
Thanks again, kind regards,
Susanna
Training information:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Excel tip:Saving your Excel Spreadsheet as a CSV FileIn situations where you need to save your Excel spreadsheet as a CSV file, follow these simple steps. |