Private Sub Worksheet_Change(ByVal r As Range)
Set r = Intersect(r, Range("B4:B" & Rows.Count), UsedRange) 'à adapter éventuellement
If r Is Nothing Then Exit Sub
Dim col%, x$, i&
col = r.Column
For Each r In r 'si entrées multiples
If r = "M1" Or r = "M2" Or r = "M3" Then
x = r
For i = r.Row - 1 To 1 Step -1
If Cells(i, col) = x Then r(1, 2) = Cells(i, col + 1) + 1: Exit For
Next i
End If
Next r
End Sub