Bonjour,
Voici, ci-dessous, un exemple de ce qui peut-être fait pour récupérer
la dernière action d'une macro
Cela n'agit que si l'on reste sur la même feuille.
1) Lancez la macro "Traitement"
2) Pour revenir à l'état initial lancez la macro "Annulation"
Code à copier dans un module standard
*********************
Sub Traitement()
Call Sauvegarde(ActiveSheet)
ActiveSheet.Range("b2") = "essai"
End Sub
Sub Annulation()
Dim S As Worksheet
Dim bool As Boolean
Dim Nom$
On Error GoTo Erreur
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Nom$ = ActiveSheet.Name
For Each S In Worksheets
If S.Name = "pmo_save" Then
S.Visible = xlSheetVisible
bool = True
Exit For
End If
Next S
If bool Then
Sheets(Nom$).Delete
Set S = Sheets("pmo_save")
S.Name = Nom$
S.Activate
End If
Erreur:
Application.ScreenUpdating = False
Application.DisplayAlerts = False
End Sub
Sub Sauvegarde(OldSheet As Worksheet)
Dim SheetSauvegarde As Worksheet
Dim S As Worksheet
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each S In Worksheets
If S.Name = "pmo_save" Then
S.Visible = xlSheetVisible
S.Delete
Exit For
End If
Next S
OldSheet.Copy before:=Sheets(1)
Set SheetSauvegarde = Sheets(1)
SheetSauvegarde.Name = "pmo_save"
SheetSauvegarde.Visible = xlSheetVeryHidden
OldSheet.Activate
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub
*********************
Cordiaalement.
PMO
Patrick Morange