+ Reply to Thread
Results 1 to 5 of 5

ComboBox DropDown list keeps adding data

  1. #1
    Forum Contributor pipoliveira's Avatar
    Join Date
    08-09-2012
    Location
    Ireland
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    368

    ComboBox DropDown list keeps adding data

    Dear All,

    I hope you are all well.

    I have a ComboBox in a UserForm with names of employees. That RowSource is from a named range called "lstNames" (updated in "Data" sheet).

    I have the following code that hides the "Empty" cells from the Named Range:
    Please Login or Register  to view this content.
    This code works perfectly as it only shows the names of employees and hides the "Empty" ones as mentioned above.

    The only problem is, if you close and open again the dropdown menu, it keeps adding the same list of employees.

    I have attached an example on this thread.

    I tried to add the following code that stops adding the repeated names, but I am unable to select any name from the list:
    Please Login or Register  to view this content.
    Any ideas on how to solve this? Your assistance will be highly appreciated.

    Best regards,
    Filipe
    Attached Files Attached Files

  2. #2
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Re: ComboBox DropDown list keeps adding data

    Good evening pipoliviera

    You've attached this macro to the DropButtonClick event, meaning it's fired every time a user clicks the combobox.
    Either run it on userform initialise, so it only runs once, or if you really need to run it under DropButtonClick, use ComboBox1.Clear first to empty it, then let it populate.

    HTH

    DominicB

  3. #3
    Forum Contributor pipoliveira's Avatar
    Join Date
    08-09-2012
    Location
    Ireland
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    368

    Re: ComboBox DropDown list keeps adding data

    Hi Dominic,

    Thanks for your reply.

    I need to run it under the DropButtonClick event because on my real workbook, the dropdown list changes depending on a previous ComboBox selection.

    As mentioned on the thread, if I add ComboBox1.Clear at the beginning of the code, I am unable to select anything from the dropdown menu.

    I have a test file attached if you want to try it yourself.

    Thanks a million in advance,
    Filipe

  4. #4
    Forum Expert dominicb's Avatar
    Join Date
    01-25-2005
    Location
    Lancashire, England
    MS-Off Ver
    MS Office 2000, 2003, 2007 & 2016 365
    Posts
    4,867

    Re: ComboBox DropDown list keeps adding data

    Hi pipliveira

    Course it does. Should of thought of that!

    Try pegging it to a different event? I tried Private Sub ComboBox1_Enter() and that seemed to work OK.
    Alternatively, populate combobox1 from the previous combobox, say the Exit event?

    HTH

    DominicB

  5. #5
    Forum Contributor pipoliveira's Avatar
    Join Date
    08-09-2012
    Location
    Ireland
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    368

    Re: ComboBox DropDown list keeps adding data

    Yep, so simple...

    Thanks a million Dominic, I am really appreciated for your help.

    I thought the drop-down list should be set on the DropDown event and nowhere else.

    Once again, thanks a million,
    Filipe

+ 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] Dropdown List in ComboBox
    By aearce2000 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-01-2014, 06:26 PM
  2. Combobox Dropdown List only shows first Item
    By Guido Meng in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-20-2013, 09:49 PM
  3. [SOLVED] Adding to ComboBox Data List
    By dagindi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-24-2012, 10:54 AM
  4. dropdown list/ComboBox
    By tullemann in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-26-2011, 01:44 PM
  5. ComboBox dropdown for a large list
    By irish1two3 in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 03-15-2007, 06:11 PM

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