+ Reply to Thread
Results 1 to 3 of 3

3 Dependent Dropdown with Combobox

  1. #1
    Registered User
    Join Date
    01-24-2021
    Location
    kedah
    MS-Off Ver
    2016
    Posts
    1

    3 Dependent Dropdown with Combobox

    Hello everyone,
    I'm new to VBA. I'm trying to make 3 dependent dropdown lists that depend on each other. I'm using user case to do this, but i'm not sure how to nestle the 3rd dropdown list options. I'm very noob, i don't need this form to be dynamic, i just need to find out how to make combo3 to depend on combo2. ( Please help me with nestled user case / if else logic/ simpler method ?)

    My data goes like this:

    1>1a>1a1
    1>1a>1a2
    1>1a>1a3
    1>1b>1b1
    1>1b>1b2
    1>1b>1b3
    1>1c>1c1
    1>1c>1c2
    1>1c>1c3

    2> 2a>2a1

    and so on ...


    __________________________________
    Private Sub UserForm_Initialize()


    ComboBox1.AddItem "1"
    ComboBox1.AddItem "2"
    ComboBox1.AddItem "3"

    End Sub

    ___________________________________
    Private Sub ComboBox1_Change()

    Dim index As Integer
    index = ComboBox1.ListIndex

    ComboBox2.Clear

    Select Case index
    Case Is = 0
    With ComboBox2
    .AddItem "1a"
    .AddItem "1b"
    .AddItem "1c"

    End With
    Case Is = 1
    With ComboBox2
    .AddItem "2a"
    .AddItem "2b"
    .AddItem "2c"
    End With
    Case Is = 2
    With ComboBox2
    .AddItem "3a"
    .AddItem "3b"
    End With
    End Select

    End Sub

    ______________________________

    # fails to work from here onwards

    Private Sub ComboBox2_Change()

    Dim index As Integer
    index = ComboBox2.ListIndex

    ComboBox3.Clear

    Select Case index
    Case Is = 1
    With ComboBox3
    .AddItem "1a1"
    .AddItem "1a2"
    .AddItem "1a3"

    End With
    Case Is = 2
    With ComboBox3
    .AddItem "1b1"
    .AddItem "1b2"
    .AddItem "1b3"
    .AddItem "1b4"
    .AddItem "1b5"
    .AddItem "1b6"
    End With

    Case Is = 2
    With ComboBox3
    .AddItem "1c1"
    .AddItem "1c2"
    .AddItem "1c3"
    End With

    Case Is = 3
    With ComboBox3
    .AddItem "2a1"
    .AddItem "2a2"
    .AddItem "2a3"
    End With


    End Select

    End Sub

    __________________________________________

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

    Re: 3 Dependent Dropdown with Combobox

    To enable us to help you - so that we can run your code without retyping please read the forum rules.
    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)

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

    Re: 3 Dependent Dropdown with Combobox

    Welcome to the forum

    Please attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

+ 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] Dependent DropDown lists in VBA /=INDIRECT() on ActiveX ComboBox/
    By bongo_bg in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-25-2018, 02:03 AM
  2. Replies: 1
    Last Post: 06-04-2018, 06:16 PM
  3. [SOLVED] ComboBox to populate Listbox and 2nd Combobox based on 1st combobox dropdown choice
    By bbqqsmokeman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-15-2017, 08:21 PM
  4. User Form Dependent Dropdown (ComboBox)
    By tmleynek in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-15-2015, 04:45 PM
  5. [SOLVED] Dependent dropdown validation - dependent data is string
    By jnewby in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-12-2014, 07:50 PM
  6. Dropdown Combobox dependent on another
    By loknath in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-17-2012, 05:08 AM
  7. Replies: 2
    Last Post: 08-11-2011, 01:32 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