+ Reply to Thread
Results 1 to 3 of 3

Have a ComboBox or Listbox be populated with data based on the value in another comboBox

  1. #1
    Forum Contributor
    Join Date
    11-30-2012
    Location
    Colorado, US
    MS-Off Ver
    MS Prof. 2010 and 2013 + 365
    Posts
    113

    Have a ComboBox or Listbox be populated with data based on the value in another comboBox

    I'm new to VBA so excuse my ignorance. I'm trying to have a ComboBox, or Listbox in a UserForm be populated with values from different ranges. Those values (or lookup choices) should be depended on the value selected in another ComboBox within the same UserForm.
    For example, if I select "Marketing" in the ComboBox "Department", I want the next Combobox/ListBox, called "Type of Work/Activity", to be populated with only the Types of Work relating to Marketing. Thus the selection choices within the "Type of Work/Activity" ComboBox/ListBox will change if I select Sales, Administration, etc. from the "Department" ComboBox.
    I assume a simple IFELSE statement will do the trick, but having difficulty figuring it out.
    I've only worked with single cell references thus far, or coded values/naming conventions directly into the VBA UserForm, and also would like to learn how to populate the ComboBox of FileBox pulling data from a lookup range. So when you add data to that range (in another sheet within the workbook) it will automatically update the selection choices in the ComboBox.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,626
    How is your data organised?
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    11-30-2012
    Location
    Colorado, US
    MS-Off Ver
    MS Prof. 2010 and 2013 + 365
    Posts
    113

    Re: Have a ComboBox or Listbox be populated with data based on the value in another comboB

    Norie,
    My data is organized like this:
    A main menu with several selection buttons that each bring up a unique UserForm.
    The data entered into each user form flows into separate sheets which function as a database. This is working nicely and is adding rows and allocating data in the right place whenever data is entered into any of the the UserForms.
    Other sheets function (and are formatted) as reporting tools based on the search criteria you enter into the reporting sheet and then pull data and populate the reports from the databases (sheet). This also is working fine.
    Other sheets are used to enter data by the user (and are used as Lookup ranges that feed into the reports), like one for employee names and their department, another one for departments with a list of the Types of Work for that department (most have 25 or more items listed), all sorted in (Named) columns with a single header starting in A1.
    None of the sheets are formatted as tables, since I'm not familiar with how VBA works with tables.
    I want to turn the latter sheets, (Employee names, Department names and functions, etc.) into lookup tables that will populate the appropriate ComboBox or FileBox in the UserForm, based on the criteria selected in the previous ComboBox.
    Thus, when the user adds a new employee name in the Employee sheet, or adds more work items to a department, this data will automatically become a selection choice in the ComboBox in the UserForm.

    Sorry my reply got a little long winded....

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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