Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ListBox1. add item myCell.entirerow Vikram Dhemare Excel Discussion (Misc queries) 3 April 8th 08 01:49 AM
Remove Item from Listbox by Item Name Randy[_2_] Excel Programming 3 September 19th 07 02:36 PM
how do i remove the item from clipboard? nano New Users to Excel 1 March 28th 06 06:45 PM
Remove subtotal where only one item Biff[_2_] Excel Programming 2 March 1st 05 02:51 PM
(Worksheet)Listbox1.additem = (Form)Listbox1.value ?? Tom Ogilvy Excel Programming 0 September 2nd 03 07:36 PM


All times are GMT +1. The time now is 09:05 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"