+ Reply to Thread
Results 1 to 5 of 5

userform combobox2 does not have unique values and will not fill listbox

Hybrid View

cfinch100 userform combobox2 does not... 09-10-2013, 05:20 PM
WHER Re: userform combobox2 does... 09-11-2013, 03:10 AM
jindon Re: userform combobox2 does... 09-11-2013, 04:26 AM
cfinch100 Re: userform combobox2 does... 09-11-2013, 12:22 PM
cfinch100 Re: userform combobox2 does... 09-11-2013, 12:19 PM
  1. #1
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    772

    userform combobox2 does not have unique values and will not fill listbox

    hi
    my userform has 2 comboboxes ,combobox2 is blank when opened,enter location number and plant numbers show but they are not unique,have various duplicate numbers but some of the info along the row is different,i would like to be able to have unique numbers in this combobox2 and to populate listbox from this one instead of combox1 populating listbox,it keeps telling me (number not found), so it is ignoring second combobox although it looks to be working,any ideas please
    cheers colin
    Attached Files Attached Files
    Last edited by cfinch100; 09-11-2013 at 12:23 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    07-29-2009
    Location
    Belgium
    MS-Off Ver
    Excel 2003/Excel 2010
    Posts
    534

    Re: userform combobox2 does not have unique values and will not fill listbox

    Try this version to see if it does what you're looking for.
    Attached Files Attached Files

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,836

    Re: userform combobox2 does not have unique values and will not fill listbox

    UserForm1?

    Option Explicit
    
    Private dic As Object
    
    Private Sub UserForm_Initialize()
        Dim a, i As Long
        Set dic = CreateObject("Scripting.Dictionary")
        dic.CompareMode = 1
        a = Sheets("sheet1").Cells(1).CurrentRegion.Resize(, 2).Value
        For i = 2 To UBound(a, 1)
            If Not dic.exists(a(i, 1)) Then
                Set dic(a(i, 1)) = _
                CreateObject("Scripting.Dictionary")
                dic(a(i, 1)).CompareMode = 1
            End If
            dic(a(i, 1))(a(i, 2)) = Empty
        Next
        Me.ComboBox1.List = dic.keys
    End Sub
    
    Private Sub ComboBox1_Change()
        With Me
            .ComboBox2.Clear
            If .ComboBox1.ListIndex > -1 Then
                .ComboBox2.List = dic(.ComboBox1.Value).keys
            End If
        End With
     End Sub

  4. #4
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    772

    Re: userform combobox2 does not have unique values and will not fill listbox

    hi jindon
    thankyou for sending info have got 2 codes looks different slightly so can have good play with them ,works well
    many thanks colin

  5. #5
    Forum Contributor
    Join Date
    10-01-2012
    Location
    england
    MS-Off Ver
    Excel 2016 pro
    Posts
    772

    Re: userform combobox2 does not have unique values and will not fill listbox

    hi wher
    excellent work many thanks does nearly exactly what I would like ,but would like to have the option of just using location then find to see all and the way you have coded it too,will have to try and dicepher the code you sent
    many thanks colin

+ 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. Userform repeat all data to next row except unique field from listbox
    By jamieswift1977 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-19-2012, 11:26 AM
  2. fill a listbox from textbox of other tab of userform in excel vba
    By kmlprtsngh in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-22-2010, 03:36 AM
  3. using a userform listbox to fill numbers in a cell
    By 2funny4words in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 05-22-2010, 01:56 AM
  4. Fill A Userform Listbox With Names OF All Open Workbooks
    By JR@SGC in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-20-2007, 05:38 AM
  5. [SOLVED] Fill a Listbox with mult. Variables in userform
    By Jennifer in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-23-2006, 02:35 PM

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