Remove Item from ListBox1
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. |
Remove Item from ListBox1
Here is the syntax,. but the best method is not to load duplicates.
ListBox1.RemoveItem (<ListIndex) "LaDdIe" wrote: 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. |
Remove Item from ListBox1
Thanks again
"JLGWhiz" wrote: Here is the syntax,. but the best method is not to load duplicates. ListBox1.RemoveItem (<ListIndex) "LaDdIe" wrote: 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. |
All times are GMT +1. The time now is 05:36 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com