• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Filter and load unique values in combox2

Mr.Karr

Member
Hello

I have an activity where I need to filter a column populate unique values from another column.

For an example: as per my selection with column A as "Vegetables"; with comboBox2, unique values or unique vegetable names from column B to load.

Presently I use:

Code:
    ComboBox1.List = Filter([transpose(if(countif(offset(A2,,,row(1:300)),A2:A300)=1,A2:A300))], "False", False)

Code:
Dim v, e
With ActiveSheet.Range("J21:J1500")
    v = .Value
End With
With CreateObject("scripting.dictionary")
    .comparemode = 1
    For Each e In v
        If Not .exists(e) Then .Add e, Nothing
    Next
    If .Count Then Me.ComboBox1.List = Application.Transpose(.keys)
End With

ComboBox2.Value = "Process Flow"

With ActiveSheet.Range("H21:H1500")
    v = .Value
End With
With CreateObject("scripting.dictionary")
    .comparemode = 1
    For Each e In v
        If Not .exists(e) Then .Add e, Nothing
    Next
    If .Count Then Me.ComboBox2.List = Application.Transpose(.keys)
End With

But with the above code, the problem is; it is not loading unique values.

I have attached a sample file. Please help.

Many thanks in advance.
 

Attachments

  • Sample file.xlsm
    18.4 KB · Views: 0
Here is one technique using an Advanced filter
 

Attachments

  • Sample file-Hui.xlsm
    20.1 KB · Views: 4
Back
Top