C
Corey
The below code populates a listbox for me, but i want ONLY unique values listed, currently i am
getting a few duplicate values populating in the listbox.
How can i remove them to ONLY display 1 value of the duplicate values ?
Private Sub ListBox1_Change()
Application.ScreenUpdating = False
If ComboBox1.ListCount > 0 Then ComboBox1.Clear
Dim LastCell As Long
Dim myrow As Long
On Error Resume Next
LastCell = Worksheets("Contact List").Cells(Rows.Count, "A").End(xlUp).Row
With ActiveWorkbook.Worksheets("Contact List")
..Select 'first thing to do with a With statement that occurs on a second sheet
For myrow = 1 To LastCell
If .Cells(myrow, 1) <> "" Then
If .Cells(myrow, 1).Offset(0, 1).Value = ListBox1.Value Then
ComboBox1.AddItem Cells(myrow, 1)
End If
End If
Next
End With
Application.ScreenUpdating = True
End Sub
Corey....
getting a few duplicate values populating in the listbox.
How can i remove them to ONLY display 1 value of the duplicate values ?
Private Sub ListBox1_Change()
Application.ScreenUpdating = False
If ComboBox1.ListCount > 0 Then ComboBox1.Clear
Dim LastCell As Long
Dim myrow As Long
On Error Resume Next
LastCell = Worksheets("Contact List").Cells(Rows.Count, "A").End(xlUp).Row
With ActiveWorkbook.Worksheets("Contact List")
..Select 'first thing to do with a With statement that occurs on a second sheet
For myrow = 1 To LastCell
If .Cells(myrow, 1) <> "" Then
If .Cells(myrow, 1).Offset(0, 1).Value = ListBox1.Value Then
ComboBox1.AddItem Cells(myrow, 1)
End If
End If
Next
End With
Application.ScreenUpdating = True
End Sub
Corey....