0
Sub deleteemptysheets()
Dim sh As Worksheet, wb As Workbook, c As Range
sh = Sheets(wb.Sheets)
    For Each c In wb.Sheets
        If IsEmpty(sh.UsedRange) Then
            sh.Delete
        End If
    Next
Set sh = Nothing
Set wb = Nothing
Set c = Nothing
End Sub

问题:我试图删除空白表,但我无法获得确切的代码。在这种情况下有人可以帮助我吗?谢谢。

4

1 回答 1

1

您没有定义wb来自哪里,也没有sh用来遍历工作表。

我假设您想遍历活动工作簿中的工作表。如果是这样,您不需要wbor c。尝试这个:

Sub deleteemptysheets()
    Dim sh As Worksheet
    For Each sh In ActiveWorkbook.Sheets
        If IsEmpty(sh.UsedRange) Then
            sh.Delete
        End If
    Next
    Set sh = Nothing
End Sub
于 2013-08-28T15:06:31.100 回答