Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete row from an Excel listbox

Status
Not open for further replies.

Epsilon101

Programmer
Mar 30, 2004
384
GB
Hi, i am trying to work out how to delete from a listbox this is what i have so far.

OptTitle is 1 of 4 option buttons, each uses a different range, the 4 ranges are displayed in listbox1, depending on which option button is clicked, for this one the sheet is "Titles" as shown below and the named range is $A:$A.

Want to be able to select one of the items in the list and delete it.

Code:
Private Sub DeleteButton_Click()
    If ListBox1.ListIndex = -1 Then Exit Sub
    ListBox1.RemoveItem ListBox1.ListIndex
End Sub

Private Sub OptTitle_Click()
ListBox1.RowSource = "Titles!TitleRange"
End Sub

Any help would be great

---------------------------------------

Neil
 
I have just seen that this doesnt work because removeitem listbox1.listindex doesnt work for bound listboxes.

There is an example on Excel vba help

Set lbcf = Worksheets(1).Shapes(2).ControlFormat
lbcf.RemoveItem lbcf.ListIndex

but i dont fully understand that, and from looking at it, i will need to reference the sheet depending on the option button that has been clicked, wondering how to do that too

---------------------------------------

Neil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top