Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am trying to remove multiple selected items from a ListBox... the code:
myListBox.RemoveItem myListBox.ListIndex only removes the last selected item. I have tried a number of things, but keep getting bad results. Does anyone have an example of this? Thanks Simon Shaw |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
for an activeX Listbox
for i = listbox.Listcount -1 to 0 step -1 if listbox.Selected(i) then listbox.RemoveItem i end if Next -- Regards, Tom Ogilvy "Simon Shaw" <simonATsimonstoolsDOTcom wrote in message ... I am trying to remove multiple selected items from a ListBox... the code: myListBox.RemoveItem myListBox.ListIndex only removes the last selected item. I have tried a number of things, but keep getting bad results. Does anyone have an example of this? Thanks Simon Shaw |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Simon,
Sub Test() Dim i As Long With Me.myListBox For i = .ListCount - 1 To 0 Step -1 If .Selected(i) = True Then .RemoveItem i End If Next i End With End Sub "Simon Shaw" <simonATsimonstoolsDOTcom wrote in message ... I am trying to remove multiple selected items from a ListBox... the code: myListBox.RemoveItem myListBox.ListIndex only removes the last selected item. I have tried a number of things, but keep getting bad results. Does anyone have an example of this? Thanks Simon Shaw |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Simon What else have you tried? What you need to do is loop through each item in the list box and check if it is selected then remove it if it is. Code: -------------------- Dim I As Integer For I = ListBox1.ListCount - 1 To 0 Step -1 If ListBox1.Selected(I) = True Then ListBox1.RemoveItem I End If Next I -------------------- -- Norie ------------------------------------------------------------------------ Norie's Profile: http://www.excelforum.com/member.php...o&userid=19362 View this thread: http://www.excelforum.com/showthread...hreadid=384197 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Last Item of Listbox not getting displayed | Excel Discussion (Misc queries) | |||
Adding item in listbox | Excel Worksheet Functions | |||
Adding item in listbox | Excel Worksheet Functions | |||
Item order in ListBox | Excel Discussion (Misc queries) | |||
The value of a ListBox Item | Excel Programming |