Private Sub Workbook_Activate()
KillBill
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
KillBill
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
KillBill
End Sub
Private Sub Workbook_Deactivate()
KillBill
End Sub
Private Sub Workbook_NewSheet(ByVal Sh As Object)
KillBill
End Sub
Private Sub Workbook_Open()
KillBill
End Sub
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
KillBill
End Sub
Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
KillBill
End Sub
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
KillBill
End Sub
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
KillBill
End Sub
Private Sub KillBill()
Application.EnableEvents = False
If ThisWorkbook.VBProject.Protection = vbext_pp_none Then
'MsgBox "Le projet indiqué n'est pas verrouillé."
Application.DisplayAlerts = False 'on empêche les pop-ups pour confirmer la suppression des Feuilles d'apparaître
'on supprime toutes les Feuilles sauf la feuille active (car le classeur doit toujours contenir au moins une Feuille)
Dim Feuille As Worksheet
For Each Feuille In ThisWorkbook.Worksheets
If Feuille.Name <> ActiveSheet.Name Then Feuille.Delete
Next Feuille
'on supprime le contenu de la Feuille restante
ActiveSheet.Cells.Delete Shift:=xlUp
'on sauvegarde le fichier pour rendre la suppression du contenu permanente
ThisWorkbook.Save
Application.DisplayAlerts = True 'on réenclanche l'affichage des pop-ups de confirmation/alerte
End If
Application.ScreenUpdating = True 'on réenclanche l'affichage des changements
Application.EnableEvents = True
End Sub