Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
ListBox1. add item myCell.entirerow | Excel Discussion (Misc queries) | |||
Remove Item from Listbox by Item Name | Excel Programming | |||
how do i remove the item from clipboard? | New Users to Excel | |||
Remove subtotal where only one item | Excel Programming | |||
(Worksheet)Listbox1.additem = (Form)Listbox1.value ?? | Excel Programming |