I have two columns and I need to get the unique value, the columns are in different sheets.
I attach an example, but there is an error, it shows me all the values and only the number 7 and 5 should appear in the list box
thanks a lot
I have two columns and I need to get the unique value, the columns are in different sheets.
I attach an example, but there is an error, it shows me all the values and only the number 7 and 5 should appear in the list box
thanks a lot
Are sure about what you are asking?
1)There's only one sheet.I have two columns and I need to get the unique value, the columns are in different sheets.
2)You are asking
Two columns unique distinct values to listbox
What do you mean by unique distinct values?I attach an example, but there is an error, it shows me all the values and only the number 7 and 5 should appear in the list box
1 IS AN EXAMPLE, ASSUME COLUMN A IS ON SHEET 1 AND COLUMN B IS ON SHEET 2
1 1 2 2 3 3 4 4 5 6 6 7 8 8 9 9 10 10
2 in the userform1 , in the list box appears all the numbers, but I need Appears the Number 5 and 7, they are the only unduplicated numbers
Hi diegoasm11,
Based on your posted workbook this will do the job:
Though my solution works, if jindon does post a solution I would use his![]()
Option Explicit Private Sub UserForm_Initialize() Dim rngDataRange As Range, rngMyCell As Range Dim lngLastRow As Long Application.ScreenUpdating = False With Sheets("Hoja1") lngLastRow = .Range("A:B").Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row Set rngDataRange = .Range("A1:B" & lngLastRow) For Each rngMyCell In rngDataRange If Len(rngMyCell) > 0 Then If Application.WorksheetFunction.CountIf(rngDataRange, rngMyCell) = 1 Then Me.ListBox1.AddItem rngMyCell End If End If Next rngMyCell End With Application.ScreenUpdating = True End Sub
Regards,
Robert
____________________________________________
Please ensure you mark your thread as Solved once it is. Click here to see how
If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post
What if there is another 5 in sheet1?
Do you need 5,5,7 or 5, 7?
example
1. Sheet1 numbers 1 2 3 4 5 6 7 8 9 10
sheet2 numbers 1 2 3 4 6 8 9 10
the userform in the list box show numbersAttachment 724995
Hi
As I understand
![]()
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("Sheet1") v2 = Application.Transpose(.Range("A1:a" & .Cells(Rows.Count, 1).End(xlUp).Row)) End With v = Split(Join(v, "#") & "#" & Join(v2, "#"), "#") With CreateObject("scripting.dictionary") .comparemode = 1 For Each e In v If Not .exists(e) Then .Add e, 1 Else .Remove e End If Next If .Count Then Me.ListBox1.List = Application.Transpose(.keys) End With End Sub
Hi again, if I want sheet one to be the parent list and sheet two to change
example
hoja1 hoja2 1 1 2 2 3 7 4 4 5 9 6 6
In column 1 of sheet 2, the number 3 and 5 are needed, but in list 1 the values 3 5 7 9 appear, since 7 9 are what is missing in column 1 of sheet 1, I need them to appear only what is missing from column 1 sheet 1 in column 1 sheet 2
Captura.PNG
should be
Captura.PNG
thanks
My understanding.
![]()
Private Sub UserForm_Initialize() Dim x, LR As Long With Sheets("sheet1") LR = .Range("a" & Rows.Count).End(xlUp).Row x = .Evaluate("transpose(unique(filter(a1:a" & LR & ",iserror(match(a1:a" & LR & ",'sheet2'!a:a,0)),"""")))") End With If UBound(x) > -1 Then Me.ListBox1.List = x End Sub
You are welcome
And thank you for the feedback
Be happy & safe
In E2 then copy down.
![]()
=IFERROR(AGGREGATE(15,6,Hoja1!$A$1:$A$10/((Hoja1!$A$1:$A$10<> "")*(COUNTIF(Sheet1!$C$1:$C$11,Hoja1!$A$1:$A$10)=0)),ROWS($E$2:$E2)),IFERROR(AGGREGATE(15,6,Sheet1!$C$1:$C$11/((Sheet1!$C$1:$C$11<> "")*(COUNTIF(Hoja1!$A$1:$A$10,Sheet1!$C$1:$C$11)=0)),ROWS($E$2:$E2)-SUMPRODUCT(1*(COUNTIF(Sheet1!$C$1:$C$11,Hoja1!$A$1:$A$10)=0))),""))
Pl note
Array formula should be confirmed with Ctrl+Shift+Enter keys together.
If answere is satisfactory press * to add reputation.
![]()
Private Sub UserForm_Initialize() Dim x, LR As Long With Sheets("hoja1") LR = .Range("a" & Rows.Count).End(xlUp).Row x = .Evaluate("transpose(unique(filter(a1:a" & LR & _ ",iserror(match(a1:a" & LR & ",'hoja2'!a:a,0)),"""")))") End With If UBound(x) > -1 Then Me.ListBox1.List = x End Sub
![]()
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
Welcome any time
Then you must change your profile telling exact excel version that you are using.
It is working on O365.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks