Sub Impression()
Dim x&, plage As Range, f As Range
Dim m As Range, rw1, rw2
Sheets("CAISSE").Activate
With ActiveSheet
x = .Range("a" & Rows.Count).End(xlUp).Row
Set plage = .Range("a1:m" & x): Set f = .Range("f20"): Set m = .Range("m4")
rw1 = Replace(f.Address, "$", ""): rw2 = Replace(m.Address, "$", "")
If .Range("f20") <> .Range("m4") Then
MsgBox "CALCUL INCORRECT : LES CELLULES " & rw1 & " et " & rw2 & " SONT DIFFÉRENTES.", , "ERREUR"
.Protect Password:="belaubre"
.Range("f20, m4").Locked = True
Else
.Unprotect Password:="belaubre"
.Range("f20, m4").Locked = False
.PageSetup.PrintArea = plage.Address
'.PrintPreview pour visualiser
'.PrintOut pour imprimer
End If
End With
End Sub