De mon point de vue, ce n'est pas cohérent de déclencher l'événement sur la colonne Z.
Au minima, c'est sur les colonnes X ou Y.
Dans le module de votre onglet
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Not Intersect(Target, Columns("X:Y")) Is Nothing Then
If Target.Row > 4 Then
MepFormule ActiveSheet
End If
End If
End Sub
Dans un module standard
Option Explicit
Sub MepFormule(ByVal Sh As Worksheet)
Dim DerniereLigne As Long
Dim AireZ As Range
With Sh
If .Cells(.Rows.Count, "X").End(xlUp).Row > .Cells(.Rows.Count, "Y").End(xlUp).Row Then
DerniereLigne = .Cells(.Rows.Count, "X").End(xlUp).Row
Else
DerniereLigne = .Cells(.Rows.Count, "Y").End(xlUp).Row
End If
Set AireZ = .Range(.Cells(5, "Z"), .Cells(DerniereLigne, "Z"))
AireZ.FormulaR1C1 = "=IF(RC[-2]="""","""",RC[-2]-RC[-1])"
End With
Set AireZ = Nothing
End Sub