+ Reply to Thread
Results 1 to 9 of 9

Combo Box Userform To Open 2nd Combo Box

  1. #1
    Registered User
    Join Date
    05-19-2010
    Location
    Alaska
    MS-Off Ver
    Excel 2003
    Posts
    4

    Combo Box Userform To Open 2nd Combo Box

    I have a Combo box Userform with selection A B C D dropdown. Want to be able to select any (in this example) B that opens a 2nd Combo Box Userform with all B's display.

    I have the 2 boxes working as desired but can't get the first box to select the appropriate (in this case B) in the 2nd Combo Box Userform.


    Private Sub ComboBox1_Change()
    Select Case ComboBox1.Value

    Case "A"
    ComboBox2.DropDown

    Case "B"

    Case "C"

    Case "D"

    End Select

    End Sub



    Private Sub Label1_Click()

    End Sub

    Private Sub UserForm_Initialize()

    ComboBox2.AddItem "A"
    ComboBox2.AddItem "B"
    ComboBox2.AddItem "C"
    ComboBox2.AddItem "D"

    End Sub


    Would also like some help on a macro for OK & Cancel button

    Not sure whether I have explained this good enough, been working on this for a couple of weeks learning VB as I go

    Wayne

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Combo Box Userform To Open 2nd Combo Box

    Welcome to the forum!

    Please read the forum rules. Rule #3 requires enclosing code in code tags (see my signature for instructions). This preserves the formatting of the code and makes it readable. You will probably want to be familiar with the other rules as well (there aren't that many!).

    Quote Originally Posted by WPJensen View Post
    ...opens a 2nd Combo Box Userform with all B's display.

    I have the 2 boxes working as desired but can't get the first box to select the appropriate (in this case B) in the 2nd Combo Box Userform.
    Sorry but I'm not following this. What do you want to be listed in the second combobox if the user selects B from the first? A concrete example might help.

    Your code has the line
    Please Login or Register  to view this content.
    This line of code simply causes the combobox to show the list. I don't know if that's what you intended. In the same place where this line of code is, you have to populate your second combobox with whatever values are appropriate for a selection of B in the first combobox. You must first use
    Please Login or Register  to view this content.
    to wipe it clean and that add whatever items you want. You can do this by associating it with a worksheet range, looping through some list, or simply adding them one by one like you have done with your first combobox.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Combo Box Userform To Open 2nd Combo Box

    BTW your cancel button will most likely be something like

    Please Login or Register  to view this content.
    which simply closes the form with no action.

    For your OK button, implementation is completely dependent on what you want to happen with the values the user has chosen, which you don't describe.

  4. #4
    Registered User
    Join Date
    05-19-2010
    Location
    Alaska
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Combo Box Userform To Open 2nd Combo Box

    Quote Originally Posted by 6StringJazzer View Post
    BTW your cancel button will most likely be something like

    Please Login or Register  to view this content.
    which simply closes the form with no action.

    For your OK button, implementation is completely dependent on what you want to happen with the values the user has chosen, which you don't describe.
    Thanks I have the cancel button working.

    As for the OK button say select B Click ok then have it open a second combo box that has a drop down list of all B.

    Then Select a B1 from that list click ok to activate exe file, I have this Step working already.
    Wayne

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Combo Box Userform To Open 2nd Combo Box

    Quote Originally Posted by WPJensen View Post
    As for the OK button say select B Click ok then have it open a second combo box that has a drop down list of all B.
    I would suggest populating and showing the second combo on change to the first one, rather than waiting for the user to click OK. In fact that's the direction that your code is already going. When you click OK it should look at the value in the second combo, and then do whatever it is you want to do with it.

  6. #6
    Registered User
    Join Date
    05-19-2010
    Location
    Alaska
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Combo Box Userform To Open 2nd Combo Box

    Quote Originally Posted by 6StringJazzer View Post
    I would suggest populating and showing the second combo on change to the first one, rather than waiting for the user to click OK. In fact that's the direction that your code is already going. When you click OK it should look at the value in the second combo, and then do whatever it is you want to do with it.
    I understand what your saying and it makes good sense only thing I do not know VB well enough to be able to make the macro to do this

    Can you help here please Thanks very much Wayne

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Combo Box Userform To Open 2nd Combo Box

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  8. #8
    Registered User
    Join Date
    05-19-2010
    Location
    Alaska
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Combo Box Userform To Open 2nd Combo Box

    Quote Originally Posted by royUK View Post
    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Sorry I have no idea what you are talking about New here and to VB

    Wayne

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Combo Box Userform To Open 2nd Combo Box

    Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here

    Various tags are explained in the link above

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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