Sub test()
With ThisWorkbook
If .Sheets.Count > 1 Then
Application.DisplayAlerts = False
.Sheets(.Sheets.Count).Delete
Application.DisplayAlerts = True
End If
End With
End Sub
Sub test()
With ThisWorkbook
If .Sheets.Count > 1 Then
Application.DisplayAlerts = False
.Sheets(.Sheets.Count).Delete
Application.DisplayAlerts = True
End If
End With
End Sub
This works for the macro that it runs on, as the last sheet is always the
one that needs to be deleted, even if it's sort of a round about way to do
(or so I think) and this part of the code only runs once.
And to think I only spent all day trying to figure this out....
Sub test()
With ActiveWorkbook
If .WorkSheets.Count > 1 Then
Application.DisplayAlerts = False
.WorkSheets(.WorkSheets.Count).Delete
Application.DisplayAlerts = True
End If
End With
End Sub
It seems that there is a tangible difference between these 2 macros
that have been suggested:-
===============================
Sub test()
With ActiveWorkbook
If .WorkSheets.Count > 1 Then
Application.DisplayAlerts = False
.WorkSheets(.WorkSheets.Count).Delete
Application.DisplayAlerts = True
End If
End With
End Sub
================================
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.