Trigger macro when nr of sheets changes
Here's one technique
Option Explicit
Dim NumSheets
Private Sub Workbook_Open()
NumSheets = ThisWorkbook.Sheets.Count
End Sub
Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
If ThisWorkbook.Sheets.Count < NumSheets Then
NumSheets = ThisWorkbook.Sheets.Count
'your code
End If
End Sub
'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code
--
HTH
Bob Phillips
(remove nothere from email address if mailing direct)
"Sige" wrote in message
oups.com...
Hi There,
I would like to trigger a maco when the nr of sheets in the active
workbook changes ...
Not: Private Sub Workbook_NewSheet(ByVal Sh As Object)
As this triggers only when a New ("Blank") Sheet is inserted.
But it should fire as well when I make a copy of an existing sheet(s).
Please?
Best Regards, Sige
|