Remove Duplicates from Listbox

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....
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top