Remove Duplicates from Listbox

  • Thread starter Thread starter Coza
  • Start date Start date
C

Coza

I did find the solution to this onece, but have seemed to lost it now.
Can some one point me int he right direction to removing any duplicate
values that are displayed in this code to populate a listbox?

Private Sub UserForm_Activate()
Application.ScreenUpdating = False
Dim LastCell As Long
Dim myrow As Long
LastCell = Worksheets("Data").Cells(Rows.Count, "C").End(xlUp).Row
With ActiveWorkbook.Worksheets("Data")
..Select
For myrow = 1 To LastCell
If .Cells(myrow, 3) <> "" Then
If .Cells(myrow, 3) <> "" Then
ListBox1.AddItem Cells(myrow, 3)
End If
End If
Next
End With
Application.ScreenUpdating = True
End Sub


Thank you in advance.

Corey....
 
try populating a collection object first

dim mycol as collection
set mycol =new collection
on error resume next
for i =1 to or some loop statement
mycol.add worksheet.cells(i,column),worksheet.cells(i,column)
loop
then fill list with collection items
 
Back
Top