+ Reply to Thread
Results 1 to 5 of 5

Combo Box2 selections available based on Combo box 1 selection

  1. #1
    Registered User
    Join Date
    07-28-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    13

    Combo Box2 selections available based on Combo box 1 selection

    So, in efforts to solve a different issue in my other users forms I thought it might be easier and fater to try something else. Is it possible to gray out or lock out combo box 2 based on what is selected in Combo box 1?

    Basically, if they choose any other country than the US in combobox1 I want the combo box2 locked out so they cant make a selection.
    If they choose US on combobox 1 then combo box2 will allow them to pick the next wet of criteria.

    Is there a way to do this? Right now this is how I have it, which allows for selections in both boxes to be made regardless of what selection is made in the first combobox1.


    Private Sub UserForm_Initialize()

    'Fill combobox1
    With Me.combobox1
    .AddItem "United States"
    .AddItem "United Kingdom"
    .AddItem "France"
    .AddItem "Germany"
    .AddItem "Spain"
    .AddItem "Italy"
    .AddItem "Netherlands"
    .AddItem "Canada"
    .AddItem "Sweden"
    .AddItem "China"
    .AddItem "Japan"
    .AddItem "Australia"
    .AddItem "Switzerland"
    .AddItem "Russia"
    .AddItem "India"
    End With
    End If
    'fill combobox2
    With Me.combobox2
    .AddItem "1"
    .AddItem "2"
    .AddItem "3"
    .AddItem "4"
    .AddItem "5"
    .AddItem "6"
    .AddItem "7"
    .AddItem "8"
    .AddItem "9"
    .AddItem "10"
    .AddItem "11"
    .AddItem "12"
    .AddItem "13"
    .AddItem "14"
    .AddItem "15"
    End With

  2. #2
    Forum Contributor
    Join Date
    01-03-2013
    Location
    Aberdeen, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    163

    Re: Combo Box2 selections available based on Combo box 1 selection

    Try this:

    Please Login or Register  to view this content.
    Very simple, but should work. Think about preventing to select any value in combobox2 before selecting value in combobox1, or it may happen that there will be a value in combobox2 when combobox1 <> US
    Last edited by Sbarro79; 07-28-2013 at 07:53 PM.

  3. #3
    Registered User
    Join Date
    07-28-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Combo Box2 selections available based on Combo box 1 selection

    So let me ask you, on this one do I do combobox1 and 2 set as
    Private Sub UserForm_Initialize() on click
    Do I leave that there and add this to the initialize info I have listed above?

    I guess, what I am trying to say is, where exactly do I put the code you gave me? LOL

  4. #4
    Forum Contributor
    Join Date
    01-03-2013
    Location
    Aberdeen, Scotland
    MS-Off Ver
    Excel 2007
    Posts
    163

    Re: Combo Box2 selections available based on Combo box 1 selection

    Not into Userform_Initialize() procedure, but above or below it
    Note, that I slightly changed my code.

  5. #5
    Registered User
    Join Date
    07-28-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Combo Box2 selections available based on Combo box 1 selection

    Oh you rock! Everything works as it should finally. Thanks for the help on this.

+ 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. combo box input range based on the other combo box selection
    By hedayet in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-08-2013, 02:27 AM
  2. Run a macro based on a Combo Box Selection
    By DBHaley in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-27-2011, 03:32 AM
  3. Populate a Combo Box based on the selection of another Combo Box
    By thunder279 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-18-2011, 03:40 PM
  4. Values of combo box dependent on selection in another combo box
    By vjboaz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-17-2008, 05:16 AM
  5. List Box selection based on combo box selection
    By MFA in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-09-2008, 10:19 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