+ Reply to Thread
Results 1 to 5 of 5

How do I handle dropdown buttons in VBA? Want current record to show the dropdown item

  1. #1
    Registered User
    Join Date
    12-10-2018
    Location
    Huntsville, AL
    MS-Off Ver
    Office 365
    Posts
    11

    Question How do I handle dropdown buttons in VBA? Want current record to show the dropdown item

    I have created data tables within my spreadsheet and I have created dropdowns in my multipage userform and I have linked those data tables to the dropdown via the RowSource property.
    I also have set up the initialize userform to load the first row of data in the worksheet so I want the current record to show the respective dropdown item of that record.
    I want the user to be able to pick a dropdown item should they want to change the current data.
    How do I properly show the current data record dropdown item but still have the table list that allows the user to pick another dropdown if needed?
    I also have a listbox set up similarly. The user has the ability to select multiple items on the list but I also want the current record to show the listed items.

    How do I properly set this up for listboxes also?

    I think what I'm really asking for is to show the selected dropdown item and selected list box items when looking at the current record.
    Last edited by mmthomas; 02-13-2021 at 09:45 PM.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: How do I handle dropdown buttons in VBA? Want current record to show the dropdown item

    Each item in the Combobox dropdown has an index number. The first item in the list is index number zero. This will select the first item in the Combobox. The same applies to the Listbox.

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    12-10-2018
    Location
    Huntsville, AL
    MS-Off Ver
    Office 365
    Posts
    11

    Re: How do I handle dropdown buttons in VBA? Want current record to show the dropdown item

    AlphaFrog,

    I am able to load the current record in the dropdown list on my userform but what I also want is for all of the options for that dropdown to show up in the list if the user decides to change that current record. The options from the table should be displayed if they click on the dropdown arrow.
    What would be the best way to make it work like that?

    I am attaching what the dropdown looks like.
    So I am pulling in the current record which is displayed in this dropdown.
    But I want the user to be able to click on the dropdown(highlighted in yellow) and see the entire list of options so they can change it if they want to.
    Right now if I click on the highlighted dropdown there's nothing to choose from.
    What would be the best way to accomplish this?
    Attached Images Attached Images
    Last edited by mmthomas; 02-14-2021 at 03:38 PM.

  4. #4
    Registered User
    Join Date
    12-10-2018
    Location
    Huntsville, AL
    MS-Off Ver
    Office 365
    Posts
    11

    Re: How do I handle dropdown buttons in VBA? Want current record to show the dropdown item

    Found a solution:
    Private Sub cmbVOCGoal1_DropButtonClick()
    Dim c As Object
    For Each c In Worksheets("Data").Range("G2:G13")
    If c.Value <> cmbVOCGoal1.Value Then
    Me.cmbVOCGoal1.AddItem c.Value
    End If
    Next c

    End Sub

  5. #5
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,302

    Re: How do I handle dropdown buttons in VBA? Want current record to show the dropdown item

    Why not populate your combobox lists during the UserForm.Initialize_Event ????

+ 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. Link Dropdown in C6:C9 to Dropdown in Column B2 (main dropdown)
    By bjnockle in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-26-2021, 09:38 PM
  2. [SOLVED] adding an item to a dropdown list via the dropdown list
    By Learning ExL in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-22-2020, 02:32 PM
  3. Replies: 1
    Last Post: 09-03-2019, 10:04 AM
  4. [SOLVED] Show first item in dropdown list instead of blank with VBA
    By thecdnmole in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-12-2018, 03:44 PM
  5. Set Value to dropdown item.
    By SAMCROWELL in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-04-2017, 06:20 PM
  6. adding new item in dropdown & using existing item as new record
    By lui de sagun in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-05-2015, 02:33 AM
  7. use dropdown and show another item automatically
    By mtsf in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-14-2013, 03:06 AM

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