删除名称以特定值开头的工作表

时间:2012-10-02 04:14:38

标签: excel vba excel-vba

我想删除名称以“data as at”开头的表格。我使用了以下但没有工作。

For Each SheetExists In Worksheets
    If Left(SheetExists.Name, 10) = "Data as at" Then
        Application.DisplayAlerts = False
        Sheets(Left("Data as at", 10)).Delete
        Application.DisplayAlerts = True
        Exit For
    End If
Next SheetExists

它返回以下行的下标错误。

Sheets(Left("Data as at", 10)).Delete

1 个答案:

答案 0 :(得分:3)

Sheets(Left("Data as at", 10)).Delete

SheetExists.Delete