Results 1 to 3 of 3

Match 2 Values from Combobox on Sheet then populate combobox with 3rd column value

Threaded View

XLVBA Match 2 Values from Combobox... 09-11-2009, 02:29 PM
Leith Ross Re: Match 2 Values from... 09-11-2009, 04:51 PM
XLVBA Re: Match 2 Values from... 09-14-2009, 08:34 AM
  1. #1
    Registered User
    Join Date
    09-11-2009
    Location
    MN
    MS-Off Ver
    Office 2010
    Posts
    48

    Match 2 Values from Combobox on Sheet then populate combobox with 3rd column value

    Edit: I see now that I should have worded the subject as "Match 2 values from Combobox TO sheet..." The comboboxes are not on the worksheet itself, they are on a userform and need to match values on a worksheet.

    I have a userform that has 3 combobox on it that we use for an inventory.

    The first combobox "firstname" has a list of usersfirst names that it pulls from Column C on the worksheet.

    Based on what they choose for "firstname" it searches that column and anytime there is a match, it will add the value next to it from Column B to my second combobox called "lastname".

    This part all works fine, but this is where I run into a problem.

    Based on what is chosen for their firstname and lastname, I need to populate the third combobox "equiptype" with the value that is in Column A, assuming that Column C matches "firstname" and Column B matches "lastname".

    This has to be completely dynamic, as users can have more than one piece of equipment, which can change. This way we can choose a piece of equipment the user has without having to guess or refer back to the worksheet.

    I can't just match it to their first or last name, because we have multiple users with the same first or the same last names, and we have to have the first and last name separate columns. And each piece of equipment has to be on a different line.

    This is how I am populating the firstname and lastname comboboxes if it makes any difference (which works very slick):
    Dim myList As New Collection
    Dim rngArea As Range
    Dim rngCell As Range
    Dim vaValues As Variant
    Dim choice As String
    Set myList = Nothing
    Set myList = New Collection
    
    choice = lastname.Value
    Set rngArea = Worksheets("Active").Range(Range("B3"), Range("B65536").End(xlUp))
    
    On Error Resume Next
    For Each rngCell In rngArea
    If choice = rngCell.Value Then
    myList.Add rngCell.Offset(0, 1).Value, CStr(rngCell.Offset(0, 1).Value)
    End If
    Next rngCell
    On Error GoTo 0
    
    For Each vaValues In myList
    firstname.AddItem vaValues
    Next
    To try to make things a little clear, here is an example:
    Column A (equipment types)
    A3- Phone
    A4- PC
    A5- Air Card
    A6- Cell Phone
    A7- Headset

    Column B (last names)
    B3- Smith
    B4- Doe
    B5- Thompson
    B6- Smith
    B7- Schmidt

    Column C (first names)
    C3- Mike
    C4- Paul
    C5- John
    C6- Mike
    C7- Mike

    So let's say I chose "Mike" for the firstname combobox and "Smith" for the lastname combobox, in the equiptype combobox I now want to see "Phone" and "Cell Phone".

    It's this equiptype combobox that is throwing me off. I can't figure out how to get it to match two pieces of criteria, and populate the third combobox.

    We have too many equiptypes and too many names to try to sort through what someone has or doesn't have, and it changes so frequently. So seeing just what they have would make the rest of the form so much smoother!

    Any help on getting the third dynamic combobox to populate would be great!
    Last edited by XLVBA; 09-14-2009 at 08:34 AM.

Thread Information

Users Browsing this Thread

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

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