+ Reply to Thread
Results 1 to 14 of 14

Userform ComboBox populating Comboboxes from worksheet data

  1. #1
    Registered User
    Join Date
    11-25-2015
    Location
    Manitoba
    MS-Off Ver
    2016
    Posts
    36

    Userform ComboBox populating Comboboxes from worksheet data

    What I am trying to accomplish is having the agent name populate cbAgentName combobox based on cbMU as well as populating cbAgent combobox. Both these comboxes should act the same as cbSkName and lbMSN. If in cbMU I choose 100 then cbAgentName and cbAgent should populate with all agents that are in the group # 100 based on columns A:C
    Also I need the lbData to populate as well but only with the agents that have skillnames and levels that do not match
    So summary is lbData should show agents name, skill name, skill level sys1 and sys2 only if the skill levels don’t match but I want the data to be pulled from the columns A:G based on what they should retrieve and the lbData should stay blank till cbMU chosen then display one instance of each agent with mismatched skills. the cbAgent and cbAgentName can be filled like what the way lbMSN is setup but again one instance of each agent not multiples like on the worksheet.
    Some background:
    Listbox (lbMSN) & ComboBox (cbSkName) rely on what a person chooses under ComboBox (cbMU)

    Worksheet GtoICheck has columns and rows that I need to populate Listbox (lbData) ComboBox (cbAgentName)
    All columns are static and cannot be changed as the empty columns seen do have data that I had to remove.
    The names of agents are dynamic so the range can vary even as deep as from A2:H1500
    Columns R:T are the Sys1 reference and are the accurate point of reference
    Column F pulls data for the agent but from a different worksheet
    Column G is formula based to look for agent in Column A and pull that agents skill Level from another sheet but for this sample I placed the values in.
    The colored cells (normally are conditional formatted) but just colored to reflect what is green is accurate and what is red is not. So level1 9 in Sys1 is =Level1 in Sys2 thus cell is green. (9=1, 5=5 and 0=0 are all accurate) but 9=5, 5=0, 0=9, 0=5 are not accurate thus they are red or would be in the conditional format formula

    What I did so far is add an array in cbMU so when 100 is chosen it displays the skill names in lbMSN and cbSkName. You will also notice the skill level in lbMSN is also displaying but if you take a look at the array it is really time consuming to try and align as what I did. If there is a way to improve on the code I used I look forward to it as I have over 40 skills, skill names and levels that are needed to be added.
    Columns R:T have the Sys1 MU’s, Skill names and levels and ideally should feed the cbMU results in lbMSN and cbSkName instead of using the array
    I really need help on the first initial problem for the cbAgentName and cbAgent to populate the way I need it too. The array would be a bonus and accepted with total gratitude as well.

    To give an idea for the array used and my apologies for ugly it looks
    Please Login or Register  to view this content.
    Any help is greatly appreciated.
    Attached Files Attached Files
    Last edited by bbqqsmokeman; 08-20-2017 at 08:20 PM.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,475

    Re: Userform ComboBox populating Comboboxes from worksheet data

    You can loop through column C and get the results to populate the other combobox

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    11-25-2015
    Location
    Manitoba
    MS-Off Ver
    2016
    Posts
    36

    Re: Userform ComboBox populating Comboboxes from worksheet data

    Davesexcel that worked great in the sample with the exception it duplicates the name and I need to somehow add in the '.RemoveDuplicates' code but when I copied the code into the original it doesn't do what it's supposed to like the sample. I had to adjust the offset to 5 to pull from column H for the agents names but it worked great in the sample. Any chance you can let me know what the '23' is after 'xlCellTypeConstants' so I have a better understanding of the code? Any chance to adjust the code to look in column A for the name or should I just leave it as column H using offset 5?

    I updated the code you supplied in the sample to include cbAgent and it works great for both comboboxes (except the duplicates at this point) but as mentioned it doesn't work in the original workbook and both comboboxes as they are blank and no error messages either.
    Last edited by bbqqsmokeman; 08-17-2017 at 12:23 PM.

  4. #4
    Registered User
    Join Date
    11-25-2015
    Location
    Manitoba
    MS-Off Ver
    2016
    Posts
    36

    Re: Userform ComboBox populating Comboboxes from worksheet data

    Well, I managed to find and piece together some code to further assist with removing duplicates from cbAgent and cbAgentName comboboxes but it only works when after launching the Userform and NOT choosing the dropdown in the cbMU combobox but the minute I use the cbMU it reverts back to the original being multiple values.
    Code that was put in the initialization code
    Please Login or Register  to view this content.
    I am still struggling with filling the listbox lbData with results from the cbMU number chosen with a range say D:G values for the group chosen in the cbMU

    Anyone have any further ideas that can assist with this challenge I am facing?

    thanks
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    11-25-2015
    Location
    Manitoba
    MS-Off Ver
    2016
    Posts
    36

    Re: Userform ComboBox populating Comboboxes from worksheet data

    well I thought I had the code to remove the duplicates in the combobox named cbAgentName but it didn't work.
    I am not certain how to or if it's possible to add .removeduplicate in the following code as I keep getting errors
    Please Login or Register  to view this content.
    so I attempted updating the vba code in the cbAgentName combobox using the following code but it does nothing and doesn't error out
    What am I doing wrong or missing? I don't want the sheet duplicates removed. Just want individual names showing in the cbAgentName combobox
    Here is the code I thought would work (not my code but adapted it to my userform and sheet)
    Please Login or Register  to view this content.
    Anyone have suggestions to my dilemna?
    Ultimately if I can get this working I will adapt the working code to include the cbAgent combobox but thought it would be good to work on one at a time.
    I have alot of work left on this userform and once the duplicate removal works then I am going to look at whoever I choose in cbAgent when clicked will show in the lbData listbox with only the values that have mismatches from the conditional format I have on the sheet; but not on the sample I supplied.

    Thank you to anyone who is willing to help a learning older guy
    Last edited by bbqqsmokeman; 08-21-2017 at 09:13 PM.

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Userform ComboBox populating Comboboxes from worksheet data

    Like this.

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  7. #7
    Registered User
    Join Date
    11-25-2015
    Location
    Manitoba
    MS-Off Ver
    2016
    Posts
    36

    Re: Userform ComboBox populating Comboboxes from worksheet data

    Thanks I added the code as suggested into the cbMU_Change and got a Compile error: variable not defined

  8. #8
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Userform ComboBox populating Comboboxes from worksheet data

    You probably are using that damn Option Explicit.

    Add this at the top of the code.

    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    11-25-2015
    Location
    Manitoba
    MS-Off Ver
    2016
    Posts
    36

    Re: Userform ComboBox populating Comboboxes from worksheet data

    Sorry I am not using Option Explicit. I prefer not to use it
    I added the Dim sn, x0,i as long and got a runtime error '13' type mismatch

    the error when debugging leads to:
    Please Login or Register  to view this content.

  10. #10
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Userform ComboBox populating Comboboxes from worksheet data

    Please Login or Register  to view this content.
    Try the example file. It does how I understand your query.
    Opening the UF some Comboboxes are prefilled. Selecting a MU populates AgentsName and Agents and gives all filtered searchresults from GtoICheck in Left side Listbox.
    When filling all Comboboxes on the right and clicking Write writes results to Audit Data Tracker and fills below listbox with all data present there.
    Don't know what you want with bot other Listboxes ?
    Attached Files Attached Files
    Last edited by bakerman2; 08-22-2017 at 03:16 AM.

  11. #11
    Registered User
    Join Date
    11-25-2015
    Location
    Manitoba
    MS-Off Ver
    2016
    Posts
    36

    Re: Userform ComboBox populating Comboboxes from worksheet data

    Bakerman2 this works extremely well and fast on the tester file.
    BIG huge thank you for cleaning up my messy code!
    I copied over the code to the actual workbook in anticipating excitement and when I ran the code it loaded but when I chose from the cbMU dropdown it just hung there and 'not responding' message. Not sure exactly what is wrong but your code is great for what I need it to do; now I need to somehow make it work in the real workbook
    Thank you very much!

  12. #12
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Userform ComboBox populating Comboboxes from worksheet data

    For that I should need to see the original file or your example file should exactly match the layout, sheetnames, objectnames etc... as the original.

  13. #13
    Registered User
    Join Date
    11-25-2015
    Location
    Manitoba
    MS-Off Ver
    2016
    Posts
    36

    Re: Userform ComboBox populating Comboboxes from worksheet data

    Bakerman2 I found the problem and removed what was causing the error and now it works fantastic! Thank you very much for all your efforts and showing me how to structure code as well.

  14. #14
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Userform ComboBox populating Comboboxes from worksheet data

    Glad you got it running.
    You're welcome and thanks for rep+.

+ 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] Populating userform textboxes basis of results from 2 userform comboboxes
    By rlh in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-11-2017, 10:26 AM
  2. [SOLVED] Filter worksheet data using 4 dependant comboboxes and populate in 'ListBox' on a userform
    By p_nayak268 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-27-2014, 12:41 PM
  3. Populating Userform ComboBox Using Items from Content Control Combobox
    By anarxo in forum Word Programming / VBA / Macros
    Replies: 2
    Last Post: 01-17-2014, 01:00 PM
  4. If multiple comboboxes not used then stop populating cells at last combobox input
    By JacobBlue in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-31-2013, 07:42 AM
  5. [SOLVED] Populating UserForm ComboBoxes with sheet entries
    By GalmOne in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-14-2012, 08:26 AM
  6. Populating comboboxes in a userform
    By metametrics in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-22-2011, 09:34 AM
  7. [SOLVED] Populating Userform ComboBox with worksheet names in XL2003
    By MAWII in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-09-2005, 05:05 PM

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