删除表格时出错.运行时错误1004:删除范围类方法失败



我正在尝试删除从列表框中选择的表格。显示表格名称的msgbox命令是正确的,但我似乎会遇到一个错误,如下所示:

运行时错误1004:删除范围类的方法失败。

这是我的代码。

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

尝试以下:

Worksheets("Report").Rows(ListBox2.ListIndex + 2).EntireRow.Delete

而不是:

Worksheets("Report").Rows(ListBox2.ListIndex + 2).Delete

(第二行)。

最新更新