如何在某张表后删除表单?

我的工作簿中有工作表作为testing 。 还有其他的工作表。 我想删除名为Test的工作表右侧出现的工作表。

我如何在VBA中做到这一点? 需要一些帮助。

编辑:

Set test= ThisWorkbook.Worksheets("Test") For i = Sheets.Count To (test.Index + 1) Step -1 Delete Sheets(i) Next 

考虑:

 Sub SheetKiller() Dim i As Long Dim j As Long j = 0 For i = 1 To Sheets.Count If Sheets(i).Name = "Test" Then j = i End If Next i If j = 0 Or j = Sheets.Count Then Exit Sub Application.DisplayAlerts = False For i = Sheets.Count To j + 1 Step -1 Sheets(i).Delete Next i Application.DisplayAlerts = True End Sub 

如果您有10张(工作表..?),并希望在testing工作表后删除所有内容,只需不断删除工作sheet(Sheets("test").Index + 1)直到工作表.count小于表格(“test”)。索引+1。

 Application.DisplayAlerts = False 'take off the training wheels Do While Sheets.Count > Sheets("test").Index Sheets(Sheets("test").Index + 1).Delete Loop Application.DisplayAlerts = True