Remove Item from ListBox1

L

LaDdIe

Hi,

I have the following code;

Private Sub UserForm_Initialize()
Dim Cell As Range, c As Range
ListBox1.Clear
For Each Cell In Sheets("Week1").Range("A4:A61")
If Cell.Value <> "" Then
For Each c In Sheets("Rota Template").Range("B5:B107")
If Cell.Value = c.Value Then
Exit For
End If
If c.Address = "$B$107" Then
With ListBox1
Me.ListBox1.AddItem Cell.Value
.List(.ListCount - 1, 1) = Cell.Offset(0, 1).Value
.List(.ListCount - 1, 2) = Cell.Offset(0, 2).Value
End With


End If
Next
End If
Next

End Sub

How can I modify it to exclude matching items already on ListBox2

Thanks.
 
J

JLGWhiz

Here is the syntax,. but the best method is not to load duplicates.

ListBox1.RemoveItem (<ListIndex>)
 

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