+ Reply to Thread
Results 1 to 19 of 19

Two columns unique distinct values to listbox

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    06-27-2010
    Location
    sYRIA
    MS-Off Ver
    Excel 2013
    Posts
    669

    Re: Two columns unique distinct values to listbox

    Private Sub UserForm_Initialize()
        Dim v, v2, e
        With Sheets("Hoja1")
            v = Application.Transpose(.Range("A1:a" & .Cells(Rows.Count, 1).End(xlUp).Row))
        End With
        With Sheets("Hoja2")
            v2 = Application.Transpose(.Range("A1:a" & .Cells(Rows.Count, 1).End(xlUp).Row))
        End With
        With CreateObject("scripting.dictionary")
            .comparemode = 1
            For Each e In v
                If Not .exists(e) Then
                    .Add e, 1
                 End If
            Next
            For Each e In v2
                If .exists(e) Then
                    .Remove e
                 End If
            Next
            If .Count Then Me.ListBox1.List = Application.Transpose(.keys)
        End With
    End Sub

  2. #2
    Registered User
    Join Date
    09-15-2018
    Location
    Colombia
    MS-Off Ver
    365
    Posts
    18

    Re: Two columns unique distinct values to listbox

    Quote Originally Posted by mohadin View Post
    Private Sub UserForm_Initialize()
        Dim v, v2, e
        With Sheets("Hoja1")
            v = Application.Transpose(.Range("A1:a" & .Cells(Rows.Count, 1).End(xlUp).Row))
        End With
        With Sheets("Hoja2")
            v2 = Application.Transpose(.Range("A1:a" & .Cells(Rows.Count, 1).End(xlUp).Row))
        End With
        With CreateObject("scripting.dictionary")
            .comparemode = 1
            For Each e In v
                If Not .exists(e) Then
                    .Add e, 1
                 End If
            Next
            For Each e In v2
                If .exists(e) Then
                    .Remove e
                 End If
            Next
            If .Count Then Me.ListBox1.List = Application.Transpose(.keys)
        End With
    End Sub
    amaizing code thanks

  3. #3
    Valued Forum Contributor
    Join Date
    06-27-2010
    Location
    sYRIA
    MS-Off Ver
    Excel 2013
    Posts
    669

    Re: Two columns unique distinct values to listbox

    Welcome any time

+ 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. unique-distinct-dependent-lists1-three-columns
    By Grace Tan in forum Excel Formulas & Functions
    Replies: 50
    Last Post: 03-16-2021, 03:40 AM
  2. Formula to extract unique values/distinct values in rows in excel
    By bjnockle in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-07-2020, 05:35 PM
  3. Replies: 0
    Last Post: 07-21-2015, 04:44 PM
  4. Create a Distinct Unique list for 2 Columns
    By boldcode in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-06-2014, 05:10 PM
  5. [SOLVED] Copy Unique Distinct Values
    By snapfade in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-17-2013, 10:33 AM
  6. Is it possible to limit a listbox based on a range to only retrieve distinct values?
    By Gvsandrs in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-15-2013, 11:58 AM
  7. Replies: 1
    Last Post: 03-02-2011, 04:14 PM

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