View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
lieven lieven is offline
external usenet poster
 
Posts: 10
Default Remove Duplicates from Listbox

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

"Coza" wrote:

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