+ Reply to Thread
Results 1 to 30 of 30

Data Validation (Dynamic) Drop Down WITH COMBO BOX, INDIRECT not working

  1. #1
    Registered User
    Join Date
    07-25-2017
    Location
    England
    MS-Off Ver
    2013
    Posts
    86

    Data Validation (Dynamic) Drop Down WITH COMBO BOX, INDIRECT not working

    Hi,
    I have been working on a spreadsheet that essentially allows a user to create a quote for clients, it takes data from a database and allows the user to sort it via a 3 tier drop down system. I have decided to overlay a combo box, when double clicked, to allow for auto completion and to stop any visual errors (when zoomed out). To do this I have found some code online (Written Below), I am average at programming but have little experience with VB, from what i can see, when double clicked the ComboBox will assign itself to the clicked cell and set "str = Target.Validation.Formula1", i.e. will set the data validation source formula as the variable str, and then sets the listfillrange as str (i.e. fills the combo box with the correct data). This would work absolutely fine had I only had one dropdown box, but It seems, that because the source formula for the data validation of the second and third tier of the drop down menu uses INDIRECT and is hence dependent on the first, that it doesn't work. I may be completely barking up the wrong tree with everything I've said here, but I'd appreciate if anyone could offer any advice.

    I cannot upload my actual document, but have been messing around with a test document that is of similar format, of which I have uploaded, the only difference being that it uses a two tier drop down, rather than three.

    Like I said, any advice is appreciated, I'd really like to know how it works and the solution, Thanks
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by georgedixon; 07-25-2017 at 07:55 PM.

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Data Validation (Dynamic) Drop Down WITH COMBO BOX, INDIRECT not working

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Valued Forum Contributor quekbc's Avatar
    Join Date
    01-18-2010
    Location
    Sydney, Australia
    MS-Off Ver
    2010, 2013, 2016
    Posts
    1,149

    Re: Data Validation (Dynamic) Drop Down WITH COMBO BOX, INDIRECT not working

    It seems like you're almost there with your data validation. Just change your data validation and remove the anchoring (i.e. in cell C2: INDIRECT($B2)) and then copy it down.

  4. #4
    Registered User
    Join Date
    07-25-2017
    Location
    England
    MS-Off Ver
    2013
    Posts
    86

    Re: Data Validation (Dynamic) Drop Down WITH COMBO BOX, INDIRECT not working

    That doesn't work, i think it's a problem with using indirect within a combo box's "listfillrange", was wondering if there was any way around it

  5. #5
    Valued Forum Contributor quekbc's Avatar
    Join Date
    01-18-2010
    Location
    Sydney, Australia
    MS-Off Ver
    2010, 2013, 2016
    Posts
    1,149

    Re: Data Validation (Dynamic) Drop Down WITH COMBO BOX, INDIRECT not working

    I have perhaps misunderstood something. The INDIRECT is working for me. You'll first need to choose a Day, before choosing Food.

    See attached.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    07-25-2017
    Location
    England
    MS-Off Ver
    2013
    Posts
    86

    Re: Data Validation (Dynamic) Drop Down WITH COMBO BOX, INDIRECT not working

    Oh sorry, I didn't explain very well, It works fine with the normal drop down box... however I have implemented some code which brings up a combo box on double click, it is when i use this, the dependent drop downs stop working. Also it seems the code i had attached to the previous file was broken, here is the corrected one. (still doesn't work with indirects though)
    Attached Files Attached Files

  7. #7
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Data Validation (Dynamic) Drop Down WITH COMBO BOX, INDIRECT not working

    Hi,

    Change the listfillrange line thus
    Please Login or Register  to view this content.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  8. #8
    Valued Forum Contributor quekbc's Avatar
    Join Date
    01-18-2010
    Location
    Sydney, Australia
    MS-Off Ver
    2010, 2013, 2016
    Posts
    1,149

    Re: Data Validation (Dynamic) Drop Down WITH COMBO BOX, INDIRECT not working

    My bad - misunderstood the request.

    As xlnitwit suggested, use the Evaluate method to get VBA to convert the INDIRECT to a proper range.

  9. #9
    Registered User
    Join Date
    07-25-2017
    Location
    England
    MS-Off Ver
    2013
    Posts
    86

    Re: Data Validation (Dynamic) Drop Down WITH COMBO BOX, INDIRECT not working

    Hi, thanks for your response, I've just tested that code and it doesn't seem to be fixing it

  10. #10
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Data Validation (Dynamic) Drop Down WITH COMBO BOX, INDIRECT not working

    It works in the sample workbook you posted.

    Actually, I stand corrected- it does not work. It was actually the data validation dropdown showing through the activex control that I was clicking. I will check further. Ah, of course- it should be
    Please Login or Register  to view this content.
    Last edited by xlnitwit; 07-26-2017 at 06:49 AM.

  11. #11
    Registered User
    Join Date
    07-25-2017
    Location
    England
    MS-Off Ver
    2013
    Posts
    86

    Re: Data Validation (Dynamic) Drop Down WITH COMBO BOX, INDIRECT not working

    Thanks allot, works perfectly. Might be an obvious question, but is there a way to make it appear on click rather than double click

  12. #12
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Data Validation (Dynamic) Drop Down WITH COMBO BOX, INDIRECT not working

    Use the SelectionChange event rather than the doubleclick event.

  13. #13
    Registered User
    Join Date
    07-25-2017
    Location
    England
    MS-Off Ver
    2013
    Posts
    86

    Re: Data Validation (Dynamic) Drop Down WITH COMBO BOX, INDIRECT not working

    Thanks again, not sure if i am being stupid but i have switched the event to SelectionChange, but i get the following error every time i click a cell: "Procedure declaration does not match description of event or procedure having same name"

  14. #14
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Data Validation (Dynamic) Drop Down WITH COMBO BOX, INDIRECT not working

    The declaration should look like this
    Please Login or Register  to view this content.

  15. #15
    Registered User
    Join Date
    07-25-2017
    Location
    England
    MS-Off Ver
    2013
    Posts
    86

    Re: Data Validation (Dynamic) Drop Down WITH COMBO BOX, INDIRECT not working

    This is the code I have, i need the cancel to remain there though. From what i can work out, defining this variable ensures that the procedure only runs on click of a cell that contains a data validation list
    Please Login or Register  to view this content.

  16. #16
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Data Validation (Dynamic) Drop Down WITH COMBO BOX, INDIRECT not working

    Quote Originally Posted by georgedixon View Post
    This is the code I have, i need the cancel to remain there though. From what i can work out, defining this variable ensures that the procedure only runs on click of a cell that contains a data validation list
    No, the Cancel is there to stop the cell going into edit mode if you double-click it. It should not be necessary if you are not using a doubleclick event and cannot be included in the declaration for a SelectionChange event.

  17. #17
    Registered User
    Join Date
    07-25-2017
    Location
    England
    MS-Off Ver
    2013
    Posts
    86

    Re: Data Validation (Dynamic) Drop Down WITH COMBO BOX, INDIRECT not working

    Oh ok thanks, I've got it working (kind of). It seems to be a bit temperamental on click, sometimes it works first time others it doesn't open the combo box and instead uses the default data validation drop down. I've attached the file I'm using if you wouldn't mind seeing where I have gone wrong
    Attached Files Attached Files

  18. #18
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Data Validation (Dynamic) Drop Down WITH COMBO BOX, INDIRECT not working

    I see what you mean- it appears to only work every second time. Perhaps that is why the original used a double-click. I will see if I can come up with a solution.

  19. #19
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Data Validation (Dynamic) Drop Down WITH COMBO BOX, INDIRECT not working

    It appears to work more reliably to delete the object each time and recreate it
    Please Login or Register  to view this content.

  20. #20
    Registered User
    Join Date
    07-25-2017
    Location
    England
    MS-Off Ver
    2013
    Posts
    86

    Re: Data Validation (Dynamic) Drop Down WITH COMBO BOX, INDIRECT not working

    Thank you so much, you're a life saver

  21. #21
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Data Validation (Dynamic) Drop Down WITH COMBO BOX, INDIRECT not working

    You're welcome.

  22. #22
    Registered User
    Join Date
    07-25-2017
    Location
    England
    MS-Off Ver
    2013
    Posts
    86

    Re: Data Validation (Dynamic) Drop Down WITH COMBO BOX, INDIRECT not working

    Sorry to be a pain, I have just made a secondary test page to see if it would work on a 3 tier drop down system and the code seems to be messing with the defined names, i.e. not showing all the options that should be in the drop down (only seems to be a problem on the first dropdown, i.e. is the opposite of the original problem I had, in that the Indirect ones are now working, but the normal one isn't).
    Attached Files Attached Files

  23. #23
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Data Validation (Dynamic) Drop Down WITH COMBO BOX, INDIRECT not working

    It's because the first one uses a row for the data, not a column. That won't work with a ListFillRange.

  24. #24
    Registered User
    Join Date
    07-25-2017
    Location
    England
    MS-Off Ver
    2013
    Posts
    86

    Re: Data Validation (Dynamic) Drop Down WITH COMBO BOX, INDIRECT not working

    haha i'm just being stupid now, thanks. Just one final question... I have copied this across to another spreadsheet where the drop down boxes are on a different page to the arrays, similar to the test page I have the first defined set as "ONE", I have changed the following, Where Sheet 2 is where the "ONE" set is, however in the dropdown on Sheet1, it is choosing the same cell reference as "ONE", but picking data from those cells from Sheet 1 instead of Sheet2
    Please Login or Register  to view this content.

  25. #25
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Data Validation (Dynamic) Drop Down WITH COMBO BOX, INDIRECT not working

    Try
    Please Login or Register  to view this content.

  26. #26
    Registered User
    Join Date
    07-25-2017
    Location
    England
    MS-Off Ver
    2013
    Posts
    86

    Re: Data Validation (Dynamic) Drop Down WITH COMBO BOX, INDIRECT not working

    This fixed the first tier, but the second and third still don't work

  27. #27
    Valued Forum Contributor quekbc's Avatar
    Join Date
    01-18-2010
    Location
    Sydney, Australia
    MS-Off Ver
    2010, 2013, 2016
    Posts
    1,149

    Re: Data Validation (Dynamic) Drop Down WITH COMBO BOX, INDIRECT not working

    I'm not 100% sure, but I believe the Evaluate method here is not really happy when dealing with named ranges from another sheet - probably to do with this code being written on Sheet1 rather than ThisWorkbook.

    So I needed to rewrite the code a fair bit - I've highlighted the changes in red below. You can also refer to the attached.

    Please Login or Register  to view this content.
    It's a bit messy, but it works. Perhaps xlnitwit has a better solution when he revisits this.
    Attached Files Attached Files

  28. #28
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Data Validation (Dynamic) Drop Down WITH COMBO BOX, INDIRECT not working

    Try a small change to what I posted previously
    Please Login or Register  to view this content.

  29. #29
    Registered User
    Join Date
    07-25-2017
    Location
    England
    MS-Off Ver
    2013
    Posts
    86

    Re: Data Validation (Dynamic) Drop Down WITH COMBO BOX, INDIRECT not working

    Thanks, they both work perfectly

  30. #30
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Data Validation (Dynamic) Drop Down WITH COMBO BOX, INDIRECT not working

    Great- don't forget to mark the thread Solved please.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Indirect data validation with dynamic range not working.
    By skyping in forum Excel General
    Replies: 3
    Last Post: 03-03-2017, 07:52 AM
  2. Dynamic Named Ranged & Indirect Data Validation
    By Voluntondile in forum Excel General
    Replies: 4
    Last Post: 10-01-2014, 08:12 PM
  3. Dynamic Named Ranges and Indirect Data validation INCOMPATIBLE?
    By css0911 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 11-08-2013, 06:17 AM
  4. Replies: 14
    Last Post: 10-02-2013, 07:39 AM
  5. Data Validation Combo Box - Indirect Function/Limit to one column
    By AlliG in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-13-2013, 07:48 PM
  6. [SOLVED] Indirect Validation after using SUBSTITUTE on a Dynamic Name Range NOT WORKING
    By Jason Eric in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-03-2013, 04:26 AM
  7. Dynamic Data validation and the indirect function
    By jboyd123 in forum Excel General
    Replies: 1
    Last Post: 01-13-2011, 06:32 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1