critério para deletar - planilhas nas posições (índice) ímpar ---> 1, 3, 5, ..., 97, ..., 365, ...
funciona se as guias estiverem ordenadas ---> Table 1, Table 2, Table 3, ...
Sub ExcluiPlansEmPosiçõesÍmpares()
Dim i As Integer, k As Long, m As Long, Plans() As Variant
k = IIf(ThisWorkbook.Sheets.Count Mod 2 = 1, ThisWorkbook.Sheets.Count, ThisWorkbook.Sheets.Count - 1)
For i = 1 To k Step 2
ReDim Preserve Plans(m): Plans(m) = Sheets(i).Name: m = m + 1
Next i
Application.DisplayAlerts = False
Worksheets(Plans).Delete
Application.DisplayAlerts = True
End Sub
critério para deletar - planilhas cujos nomes terminem com número ímpar ---> Table 1, Table 3, Table 5, ..., Table 97, ..., Table 365, ...
Sub ExcluiPlansComÍmparNoNome()
Dim ws As Worksheet
Application.DisplayAlerts = False
For Each ws In ThisWorkbook.Sheets
If Right(ws.Name, Len(ws.Name) - 6) Mod 2 = 1 Then ws.Delete
Next ws
Application.DisplayAlerts = True
End Sub
Postado : 02/04/2017 2:47 pm