Deleting / Inserting a sheet should invoke the Sheet Activate event.
In theory you could on that basis use that Workbook level event to store a Static variable keeping track of the number of sheets in that workbook.
As and when the number changes invoke the other routine.
(the Static will be lost between "sessions" so the code will also fire the first time the workbook calculates)
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Static lngWs As Long
On Error Resume Next
If ThisWorkbook.Sheets.Count <> lngWs Then
'new sheet or sheet removed
'disable events
Application.EnableEvents = False
'do stuff....
'enable events
Application.EnableEvents = True
'update Static
lngWs = ThisWorkbook.Worksheets.Count
End If
End Sub
the above would reside in ThisWorkbook in VBE
(the above would need to usurp the NewSheet event - not ideal but as outlined in should cater for both insertion & deletion simultaneously)
Bookmarks