I have the following code which will delete a sheet from the spreadsheet when it is selected in the userform, but I need this also to be deleted from the list in the userform so that it is not there next time it is opened.
I have tried:
listbox1.removeitem(lItem) before the endif, but this doesn't seem to work.
I am not sure that each time the userform is opened that it fills the list with the correct sheets. Will it retain those that were entered on the last open?
I hope you can help me! I've been struggling with this for a few days!
Sam
I have tried:
listbox1.removeitem(lItem) before the endif, but this doesn't seem to work.
Code:
Private Sub CommandButton1_Click()
Dim lItem As Long
For lItem = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(lItem) = True Then
Sheets(ListBox1.List(lItem)).Delete
End If
Next
UserForm1.Hide
End Sub
I am not sure that each time the userform is opened that it fills the list with the correct sheets. Will it retain those that were entered on the last open?
I hope you can help me! I've been struggling with this for a few days!
Sam