+ Reply to Thread
Results 1 to 16 of 16

third level of dynamic combo box

Hybrid View

  1. #1
    Registered User
    Join Date
    01-20-2016
    Location
    Indonesia
    MS-Off Ver
    2013
    Posts
    25

    third level of dynamic combo box

    Hi, and Happy New Year...

    This is my first time in creating a user form, and I encountered a problem with third level of dynamic combo box in user form.
    Can someone help me with this problem, preferably with some explanation of the code.

    A brief explanation of the problems:

    - there are 3 combo boxes that supposedly link to each other. Ideally, the first level will generate list of the second level, and the second level will generate list of the third level.
    - I am using "select case" in defining the second level (easiest one in my opinion, or if you could direct me to other similar function).
    - I can't figure it out how to connect the third to the second level.

    Thank you for your time.

    I've included an example file.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: third level of dynamic combo box

    Private Sub cbcat1_Click()
    With Sheets("category")
        mycol = .Cells.Find(cbcat1, .Cells(1), lookat:=xlPart).Column
        lr = .Cells(.Rows.Count, mycol).End(xlUp).Row
        arr = .Range(.Cells(2, mycol), .Cells(lr, mycol))
        cbcat2.List = arr
    End With
    End Sub
    
    Private Sub cbcat2_Click()
    With Sheets("category")
        mycol = .Cells.Find(cbcat2, .Cells(1), lookat:=xlPart).Column
        lr = .Cells(.Rows.Count, mycol).End(xlUp).Row
        arr = .Range(.Cells(2, mycol), .Cells(lr, mycol))
        cbcat3.List = arr
    End With
    End Sub
    Kind regards
    Leo
    Attached Files Attached Files

  3. #3
    Valued Forum Contributor meabrams's Avatar
    Join Date
    10-03-2014
    Location
    USA
    MS-Off Ver
    2007, 2010, 2013, 2016
    Posts
    451

    Re: third level of dynamic combo box

    The reason yours is failing on the 3rd cat is you are trying to use .ListIndex instead of .Value

    c2_red = Me.cbcat2.Value
    Bramz

  4. #4
    Valued Forum Contributor meabrams's Avatar
    Join Date
    10-03-2014
    Location
    USA
    MS-Off Ver
    2007, 2010, 2013, 2016
    Posts
    451

    Re: third level of dynamic combo box

    Leo's way is better but I just wanted to see what was causing your way to fail.

    .ListIndex grabs the index number from 0 to n where as .Value grabs the Value
    Last edited by meabrams; 01-03-2017 at 05:25 AM. Reason: keyboard issues

  5. #5
    Registered User
    Join Date
    01-20-2016
    Location
    Indonesia
    MS-Off Ver
    2013
    Posts
    25

    Re: third level of dynamic combo box

    Hello Leo. Thank you for the help.

    If you don't mind, could you explain step by step of the code?
    I'm trying to understand the code, to be able to replicate it.
    I have tried to replicate it with more category, but the 2nd level show the same one as the first one.
    Is it have to do with the find function?

    Thank you again.

  6. #6
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: third level of dynamic combo box

    I ame not good in explication but give it a try
    1 code for each ComBobox

    Code for first ComboBox has to be in Userform_Ini......
    Others in ComboBox_Click

    Private Sub cbcat1_Click()
    With Sheets("category")  ' sheet name with data
        mycol = .Cells.Find(cbcat1, .Cells(1), lookat:=xlPart).Column  ' find column that contains the contents of ComboBox cbcat1
        lr = .Cells(.Rows.Count, mycol).End(xlUp).Row  ' find the last row of this column
        arr = .Range(.Cells(2, mycol), .Cells(lr, mycol))  ' put the values of this column in a array
        cbcat2.List = arr  ' put the array in the list of next ComBobox
    End With
    End Sub
    Kind regards
    Leo

  7. #7
    Registered User
    Join Date
    01-20-2016
    Location
    Indonesia
    MS-Off Ver
    2013
    Posts
    25

    Re: third level of dynamic combo box

    Hi Leo, thanks for the explanation.

    I tried to replicate it again, but now the code is not working.
    I read some code for generating the combo box, but when I applied the code. I run into error code 70. Therefore I delete it.

    I've included the example in attachment.
    The "Room" combo box derrived from the "Location" combo box.
    The "Category", "Type", and "Made From" combo box is the 1st. 2nd, and 3rd dependant combo boxes.

    Sorry for the brief explanation.
    Attached Files Attached Files
    Last edited by da.se; 01-05-2017 at 01:34 AM.

  8. #8
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: third level of dynamic combo box

    In this file it is not clear to me what has to come in the depend boxes

    you have 5 locations, lets say we choose 2 what has to come in next ComBobox ?

    Kind regards
    Leo

  9. #9
    Registered User
    Join Date
    01-20-2016
    Location
    Indonesia
    MS-Off Ver
    2013
    Posts
    25

    Re: third level of dynamic combo box

    Hi Leo.

    In the file,
    - location combo box refers to "Kode 00" or in the name library "lok"
    * "01" refers to name library "ger"
    * "02" and "03" refers to name library "pas"
    * "04" refers to name library "bin"
    * "05" doesn't refers to anything (blank)

    - category combo box refers to "kode 04" or name library "bar"
    * "ACO" refer to name library "kode05"
    * ...
    * "KBM" refer to name library "kode14"
    - in type combo box ("kode 04"), each of "ETN", "PNJ", "MUS", "PNR", "KMT", "PRT", and "ATK" derivatives, will refer to "kode15" or in the name library "bah" (third level). While "ACO", "CET", and "KBM" doesn't have derivatives (doesn't have a third level)
    - the condition and status combo box is just simple one level combo box.

    I hope that I explain it right

    Thank you.
    Last edited by da.se; 01-05-2017 at 05:47 AM.

  10. #10
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: third level of dynamic combo box

    Quote Originally Posted by da.se View Post
    Hi Leo.

    In the file,
    - location combo box refers to "Kode 00" or in the name library "lok"
    * "01" refers to name library "ger"
    * "02" and "03" refers to name library "pas"
    * "04" refers to name library "bin"
    * "05" doesn't refers to anything (blank)

    - category combo box refers to "kode 04" or name library "bar"
    * "ACO" refer to name library "kode05"
    * ...
    * "KBM" refer to name library "kode14"
    - in type combo box ("kode 04"), each of "ETN", "PNJ", "MUS", "PNR", "KMT", "PRT", and "ATK" derivatives, will refer to "kode15" or in the name library "bah" (third level). While "ACO", "CET", and "KBM" doesn't have derivatives (doesn't have a third level)
    - the condition and status combo box is just simple one level combo box.

    I hope that I explain it right

    Thank you.
    see red lines


    Kind regards
    Leo

  11. #11
    Registered User
    Join Date
    01-20-2016
    Location
    Indonesia
    MS-Off Ver
    2013
    Posts
    25

    Re: third level of dynamic combo box

    Hmmm...

    So basically,

    What I intended is,
    There are 2 series of combo boxes which has its own dependent combo boxes. And one of them has a third dependent combo box.

    But,
    Because of the way the code works, there can be only one series of combo boxes?

  12. #12
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: third level of dynamic combo box

    No

    i see 2 times 04 with other library

  13. #13
    Registered User
    Join Date
    01-20-2016
    Location
    Indonesia
    MS-Off Ver
    2013
    Posts
    25

    Re: third level of dynamic combo box

    Ah.. I see.

    The first "04" refers to the cell A5.
    It's part of the "Location" combo box list.
    The second, which is "Kode 04", refers to the cell E1.
    It's a text data. In the name library, the data in column E are named "bar".

    Will it be a problem? naming it almost identical?

  14. #14
    Registered User
    Join Date
    01-20-2016
    Location
    Indonesia
    MS-Off Ver
    2013
    Posts
    25

    Re: third level of dynamic combo box

    Hi Leo.

    i see 2 times 04 with other library
    I'm sorry, but can you be specific?
    I tried to look for duplicate, but didn't find any (or maybe I didn't see it).

  15. #15
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: third level of dynamic combo box

    If you want depended boxes
    the code has to search (search criteria is the contents of previus combo) the column where is the data
    in this file not possible

    Cheers
    Leo

  16. #16
    Registered User
    Join Date
    01-20-2016
    Location
    Indonesia
    MS-Off Ver
    2013
    Posts
    25

    Re: third level of dynamic combo box

    Thank you Leo.
    Good day to you.

+ 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. Create dynamic multi level reference ID (eg. 1.1.1, 1.1.2 etc)
    By ChrisNor in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-10-2017, 11:33 PM
  2. [SOLVED] need dynamic cell address for mid level data validation dead end
    By Polymorpher in forum Excel General
    Replies: 14
    Last Post: 09-18-2014, 11:47 AM
  3. Dynamic Multi-Level list
    By glosos in forum Excel General
    Replies: 2
    Last Post: 09-04-2014, 03:39 PM
  4. Posisible to Disable Save As at Program level (not workbook level)??
    By brian6464 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-29-2014, 02:49 PM
  5. Bill of Materials conversion from multi level to single level
    By susmitpatel in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 07-11-2013, 12:53 AM
  6. Can't get VBA code to do task at worksheet level not workbook level
    By lealea1982 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-12-2011, 10:22 AM
  7. Using macro to convert single level BOM to Multi Level BOM
    By andrew_chong in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-07-2006, 04:57 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