+ Reply to Thread
Results 1 to 9 of 9

data in form Combobox2 depends on selection from Combobox1

  1. #1
    Registered User
    Join Date
    04-24-2014
    Location
    melbourne,australia
    MS-Off Ver
    Excel 2010
    Posts
    40

    data in form Combobox2 depends on selection from Combobox1

    Hello,

    I need some help with combobox's.. I have it working as I need it to with Active-x combobox but I need to move to a form method because the Active-x combobox is buggy in the worksheet and has these strange font and box resizing issues which there is no solution to out there.. Something about if you have external monitor or projector plugged in and it using a different resolution to what your native laptop or pc is using.. doesn't make any sense to me and unfortunately I have given up on it.

    Problem is what I want doesn't seem like it can be done with form combobox but I will seek your support first before I come to that conclusion.

    So using form Combobox, this is my setup:

    Combobox1 contains a short list of Teams i.e. ENT,MEL,EMEA,MTVSSL,TSJ -- I am referencing this from the FORMAT CONTROL property Input Range: TEAMS!A2:A6
    Combobox2 I need to list the names of the people in those teams i.e. John Doe etc.. I have column with teams as headers and the people in each column in the respective teams. i.e. B1:B16 has the list of people for the team called ENT (B1 is the header "ENT") and B2:B16 is the names of the people.

    Problem is I don't know how I can link the two based on selection in Combobox1?

    One catch, I prefer not to hard code the names of people in any code, if I can reference from a table or cell that would be better as the list of people within a team will increase over time.

    As always, appreciate anyone's guidance.
    Last edited by emortals; 04-25-2014 at 12:56 AM.

  2. #2
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: data in form Combobox2 depends on selection from Combobox1

    What you are describing is called cascading combobox/listbox.

    There are dozens of examples on the net.

    But, I'm feeling generous today and have provided an example.

    Basically, you search for the team column header and fill combobox until lastrow.

    This code is dynamic, both on teams names and member names, meaning the list can change without modifying the code.
    Attached Files Attached Files
    David
    (*) Reputation points appreciated.

  3. #3
    Registered User
    Join Date
    04-24-2014
    Location
    melbourne,australia
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: data in form Combobox2 depends on selection from Combobox1

    Quote Originally Posted by Tinbendr View Post
    What you are describing is called cascading combobox/listbox.

    There are dozens of examples on the net.

    But, I'm feeling generous today and have provided an example.

    Basically, you search for the team column header and fill combobox until lastrow.

    This code is dynamic, both on teams names and member names, meaning the list can change without modifying the code.
    David, appreciate your generosity. What you produced is more or less what I am trying to achieve, however, I was looking to do this within the worksheet using the form combobox. I created the form comboxbox from the toolbar not in VB userform. I apologise if I was not clear enough. Your example has certainly given me another perspective on things and may explore that at another time but for now i want to keep things within the worksheet.

    Again, I have it working as a Active-x comboxbox but given the issues with external monitors/projectors etc I want to see if the same can be achieved with regular form comboxes.

    I have updated the worksheet you sent to illustrate what I am looking for, it should be much easier to understand if you look at the attached worksheet
    1006634-Cascading comboboxes(2).xlsm

  4. #4
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: data in form Combobox2 depends on selection from Combobox1

    Here's all solutions. (Forms are a pain in the ****.!)
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    04-24-2014
    Location
    melbourne,australia
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: data in form Combobox2 depends on selection from Combobox1

    Quote Originally Posted by Tinbendr View Post
    Here's all solutions. (Forms are a pain in the ****.!)
    You nailed it! Only thing missing is how to output the value in ComboBox2 to a cell, J11 for example. I right click on ComboBox2 and added a cell reference but it only gives the index number and not the text value.

    Can you advise of a VB string I could use? I tried some but maybe I am not adding it in the right place in your code

    Right after this line "Sheet1.ComboBox2.AddItem .Cells(A, C.Column)" I added the following but it didnt work:

    J11 = ComboBox2.Value

    Thanks!

  6. #6
    Forum Expert Tinbendr's Avatar
    Join Date
    06-26-2012
    Location
    USA
    MS-Off Ver
    Office 2010
    Posts
    2,138

    Re: data in form Combobox2 depends on selection from Combobox1

    Either one of these in the Combobox1_Change event

    Please Login or Register  to view this content.
    (Or manually right -click, properties, Link to cell J11

    Just for prosperity, I edited the file once more to fix a couple of things and to add values to sheet.
    Attached Files Attached Files
    Last edited by Tinbendr; 04-26-2014 at 04:30 AM.

  7. #7
    Registered User
    Join Date
    04-24-2014
    Location
    melbourne,australia
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: data in form Combobox2 depends on selection from Combobox1

    Quote Originally Posted by Tinbendr View Post
    Either one of these in the Combobox1_Change event

    Please Login or Register  to view this content.
    (Or manually right -click, properties, Link to cell J11

    Just for prosperity, I edited the file once more to fix a couple of things and to add values to sheet.
    Thanks! it works as expected. Appreciate your efforts

  8. #8
    Registered User
    Join Date
    04-24-2014
    Location
    melbourne,australia
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: data in form Combobox2 depends on selection from Combobox1

    Starting to feel a little rude with the extra question. I was copying your code to my worksheet and I just realised my tables with teams and people are in another sheet from where the ComboBoxes will be.. the sheet for the team names and people is called NOTES and sheet with ComboBoxes is called Global Talent

    The data is laid out exactly as you had it in your sample worksheet Column A for teams and B through F for the people.

    Is it simple enough to add the sheet name in all the right places? You have already been a great help and I would really appreciated your guidance on this.

    thanks,

  9. #9
    Registered User
    Join Date
    04-24-2014
    Location
    melbourne,australia
    MS-Off Ver
    Excel 2010
    Posts
    40

    Re: data in form Combobox2 depends on selection from Combobox1

    Quote Originally Posted by emortals View Post
    Starting to feel a little rude with the extra question. I was copying your code to my worksheet and I just realised my tables with teams and people are in another sheet from where the ComboBoxes will be.. the sheet for the team names and people is called NOTES and sheet with ComboBoxes is called Global Talent

    The data is laid out exactly as you had it in your sample worksheet Column A for teams and B through F for the people.

    Is it simple enough to add the sheet name in all the right places? You have already been a great help and I would really appreciated your guidance on this.

    thanks,
    I seem to have worked it out.. I could not use a space in the sheet name and I added in infront of the .Cells and .Range Worksheets("NOTES")

    Thank you for your kindness to help me achieve this task!!

+ 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. listbox of combobox2 depends on value choosen from listbox of combobox1
    By hassan khansa in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-30-2013, 12:11 PM
  2. Disabling dependent combobox2 until selection is made in combobox1
    By newqueen in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-24-2013, 11:25 AM
  3. [SOLVED] items in combobox2 depending on combobox1
    By minifreak in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-15-2012, 10:52 AM
  4. combobox1 selection to determine combobox2 selection
    By krismatthews in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-11-2012, 01:36 PM
  5. Combobox2 dependent on Combobox1
    By teacher_rob in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 11-19-2011, 10:10 AM

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