Private Sub Workbook_Open()
'mon code existant
Worksheets("Facture").Protect Password:="", UserInterfaceOnly:=True
Worksheets("FactCom").Protect Password:="", UserInterfaceOnly:=True
Sheets("Facture").Select
ActiveSheet.Protect Password:="", DrawingObjects:=True, Contents:=True, Scenarios:=True
ActiveSheet.EnableSelection = xlUnlockedCells
If Sheets("FactCom").Range("m11") <> "" Then
Dim ret As Integer
ret = MsgBox("Effacer le contenu de FactCom ?", vbYesNo)
If ret = vbNo Then
Exit Sub
Else
Efface_Com
End If
End If
End Sub
'Gérard
Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
ThisWorkbook.Names.Add "Feuille_Precedente", Sh.Name
End Sub
Sub Retour()
'se lance par les touches Ctrl+R
On Error Resume Next
Sheets([Feuille_Precedente]).Activate
End Sub
'TooFatBoy Feuille Facture
Private Sub Workbook_BeforeClose(Cancel As Boolean)
ActiveWorkbook.Save
If Workbooks.Count = 1 Then Application.Quit Else ThisWorkbook.Close
End Sub
'Gérard Modules
Option Explicit
Dim FeuillePrecedente As String
Sub Aller()
'ROLE : Enregister le nom de la feuille en cours en vu d'y retourner après l'execution d'une macro
FeuillePrecedente = Sheets("Facture").Name
End Sub
Sub Retour()
'ROLE : Retourner à la feuille précédente
Sheets("Facture").Select
End Sub