I am trying to delete a sheet selected from a list box. The msgbox commands displaying the sheet names are correct but I seem to get an error which is as below:
Runtime Error 1004: Delete method of range class failed.
Here is my code.
If ListBox2.Selected(i) Then
Worksheets(ListBox2.List(i)).Unprotect "asdf"
Worksheets(ListBox2.List(i)).Delete
MsgBox ListBox2.List(i)
sht = ListBox2.List(i) + "_Graph"
Worksheets(sht).Unprotect "asdf"
MsgBox sht
Worksheets(sht).Delete
Worksheets("Report").Rows(ListBox2.ListIndex + 2).Delete
MsgBox "KC " + ListBox2.List(i) + " Removed!"
End If
deletemethod, and you could not be bothered to tell us which line is failing .... and the last command is amsgboxcommand ..... since you said that the msgbox commands display the correct sheet names, no none of thedeletemethods in the code are failing. ... your problem is someplace else - jsotolaDeletemethod onRangeobject. - Michał Turczyn