Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Not Me.Saved Then Me.Save 'évite l'invite à la fermeture
End Sub
Private Sub Workbook_Deactivate()
Dim nomfich$, fichier$, source As Range, wb As Workbook, dest As Range, col, i&, j%
nomfich = "resultats2.xlsx"
fichier = ThisWorkbook.Path & "\" & nomfich
If Dir(fichier) = "" Then MsgBox "Le fichier '" & nomfich & "' est introuvable !", 48: Exit Sub
On Error Resume Next: Set wb = Workbooks(nomfich): On Error GoTo 0
Set source = Me.Sheets(1).[G4]
Application.ScreenUpdating = False
Application.EnableEvents = False
If Not Me.Saved Then Me.Save
If wb Is Nothing Then Workbooks.Open fichier Else wb.Activate 'ouverture du fichier s'il n'est pas ouvert
With ActiveWorkbook
Set dest = .Sheets(1).[B88] 'modifiable
col = Array(1, 3, 5, 6, 8, 10, 11) 'numéros des colonnes
For i = 1 To 24
For j = 1 To 7
dest(i, col(j - 1)) = source(i, j)
Next j
If i Mod 2 Then dest(i, 12) = "=(RC[-9]+RC[-6])/RC[-1]"
Next i
If wb Is Nothing Then .Close True Else .Save 'enregistrement et fermeture du fichier si nécessaire
End With
Application.EnableEvents = True
End Sub