+ Reply to Thread
Results 1 to 5 of 5

VBA 2007 user form combo box dynamic range row source problem

  1. #1
    Registered User
    Join Date
    04-29-2013
    Location
    Brisbane
    MS-Off Ver
    Excel 2007
    Posts
    21

    VBA 2007 user form combo box dynamic range row source problem

    Hi

    I have created 3 combo boxes on a user form. I have set up dynamic ranges in excel that change depending on the user's selection ie - choose an option for combo box 1, the ItemList for combo box 2 will then update, and so on. I am using row source in each combo box to reference the relevant dynamic range.

    I am finding that there can be a time delay in ItemList updating for subsequent combo boxes and if you click too quickly into the next combo box, you actually see the items relevant to the original selection in the previous combo box.

    Have I done something wrong? Is this a known problem? More importantly, is there a way to make this work properly?

    Thanks

  2. #2
    Registered User
    Join Date
    04-30-2013
    Location
    Brussels
    MS-Off Ver
    Excel 2007
    Posts
    35

    Re: VBA 2007 user form combo box dynamic range row source problem

    Dear jane,

    Make sure that you have this in your code :

    Please Login or Register  to view this content.
    See if that does the trick.

    Have fun!
    ExcelTab.com

  3. #3
    Registered User
    Join Date
    04-29-2013
    Location
    Brisbane
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: VBA 2007 user form combo box dynamic range row source problem

    Hi

    I have tried your suggestions but it hasn't worked (the cursor doesn't even change to an egg timer as the code runs too quickly). I have tried adding a 'sleep' command but this slows the performance of the form and I still occasionally get the problem of the 'old' list populating the combo box.

    I have tried a few other options as well but am still getting the problem intermittently. At the moment, the code is working as follows:
    1. get ComboBox 1 value from the user
    2. save this value to a worksheet
    3. calculations in the worksheet examine the data to determine the unique values that match ComboBox 1 selection
    4. a dynamic range name in the worksheet (using Offset and Count) defines the list for ComboBox 2 (List2)
    5. the VBA code populates ComboBox 2 with the List2
    6. the user chooses a value from ComboBox 2
    7. save this value to the worksheet
    8. calculations in the worksheet examine the data to determine the unique values that match ComboBox 1 and ComboBox 2 selection
    9. a dynamic range name in the worksheet (using offset and count) defines the list for ComboBox 3 (List3)
    10. the VBA code populates ComboBox 3 with the List3

    I have changed the dynamic range to use Max rather than Count and moved it to the code ie - the List to populate the combo boxes is calculated in VBA using Evaluate. This has improved the issue with the combo boxes populating with the most recent data but it is still not 100% reliable.

    The problem definitely seems to be the delay between saving the data to the worksheet and defining the new combobox List, and then populating the combobox with the List.

    What do I need to do? Should I forget dynamic ranges and revert to static lists? Do all the calculations need to be moved to VBA (I'm not keen to do this as I am relatively new to programming but far more confident using worksheet formula)?

    I am desperate for a solution as this part of the form is key to the application and needs to be 100% reliable (particularly given that the current data set is relatively and will be increasing significantly).

    Thanks

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643
    Can we see the code and/or a sample workbook?
    If posting code please use code tags, see here.

  5. #5
    Registered User
    Join Date
    04-29-2013
    Location
    Brisbane
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: VBA 2007 user form combo box dynamic range row source problem

    Hi Norrie

    I cannot post the actual file as it contains confidential info but I have prepared an example. How do I load it - I don't seem to have an 'attach' option.

    Thanks

    Found it - here's the file - just run the userform. Clicking around only sometimes replicates the error - in this case I was only able to get 'zeroes' in the 'fruit'.
    Attached Files Attached Files
    Last edited by jane serky; 06-16-2013 at 03:44 AM. Reason: To attach file and add comment

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: VBA 2007 user form combo box dynamic range row source problem

    Jane

    The userform in the workbook you uploaded seems to work just fine with no slowdowns.

    Is there anything else in the actual workbook that could be slowing things down.

    For example event code.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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