Results 1 to 3 of 3

Removing Duplicates from ComboBox and Populating one combobox based on another

Threaded View

  1. #1
    Registered User
    Join Date
    06-27-2010
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    16

    Removing Duplicates from ComboBox and Populating one combobox based on another

    Hello everyone,

    First let me say that your team of specialists has help my job a lot easier, and I have learned quite a lot from your advise, for which I am very thankful. Now on to the task at hand, I am trying to "remodel" our purchasing agents database, and I need help with combo box functionality. Basically, I am populating my First Name and Last Name combo boxes based on ranges in my spreadsheet. However, First or Last Names may duplicate. I would like my combo box to use only unique instances for the first name, then based on the first name selection, populate the last name combo box. Then based on the combination of First and last name, provide the remaining information in the available text boxes. I have created custom search forms before but typically only one combo box, and because the amount of purchasing agents is over 200, a single combo box with first and last name is not very practical. Any help you can lend me is very welcomed. I have attached a sample file with bogus data for your convenience.

    Below is the code I am using to initialize my form

    Private Sub UserForm_Initialize()
    Dim lFirst As Range
    Dim lLast As Range
    Dim ws As Worksheet
    Set ws = Worksheets("Accounts")
    
    
    For Each lFirst In ws.Range("FirstList")
      With Me.cboFirst
        .AddItem lFirst.Value
        .List(.ListCount - 1, 1) = lFirst.Offset(0, 1).Value
      End With
    Next lFirst
    
    For Each lLast In ws.Range("LastList")
      With Me.cboLast
        .AddItem lLast.Value
      End With
    Next lLast
    
    Me.cboFirst.SetFocus
    End Sub
    Attached Files Attached Files

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