![]() |
listbox remove item according to the value
hi All,
I have a list box which displays the sheet names from 201 to 843(these are the names of the worksheets).What I need,when I click on command button if the checkbox1 is check then remove all the item less then 800 from the list. So far I made the below code but I only removes one item less than 800.How can I remove all the items less than 800É If CheckBox1.Value = True Then Dim i As Long For i = 0 To Me.ListBox1.ListCount - 1 If Me.ListBox1.List(i) < 800 Then Me.ListBox1.RemoveItem (i) Exit Sub End If Next i End If Thanks for help and happy new year. |
listbox remove item according to the value
If CheckBox1.Value = True Then
Dim i As Long For i = Me.ListBox1.ListCount - 1 To 0 Step -1 If Me.ListBox1.List(i) < 800 Then Me.ListBox1.RemoveItem (i) End If Next i End If -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) wrote in message ... hi All, I have a list box which displays the sheet names from 201 to 843(these are the names of the worksheets).What I need,when I click on command button if the checkbox1 is check then remove all the item less then 800 from the list. So far I made the below code but I only removes one item less than 800.How can I remove all the items less than 800É If CheckBox1.Value = True Then Dim i As Long For i = 0 To Me.ListBox1.ListCount - 1 If Me.ListBox1.List(i) < 800 Then Me.ListBox1.RemoveItem (i) Exit Sub End If Next i End If Thanks for help and happy new year. |
All times are GMT +1. The time now is 01:29 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com