Private Sub Worksheet_Change(ByVal Target As Range)
Dim P As Range, a, i%
Set P = [A1:D2]
'---initialisation---
If Not IsArray([Memo]) Then
ReDim a(1 To 2, 1 To P.Columns.Count)
For i = 1 To P.Columns.Count
a(1, i) = ""
a(2, i) = 0
Next
ThisWorkbook.Names.Add "Memo", a 'nom défini
End If
'---comptage---
a = [Memo]
For i = 1 To P.Columns.Count
If CStr(P(1, i)) <> a(1, i) Then
a(1, i) = CStr(P(1, i))
a(2, i) = a(2, i) + 1
End If
Next
'---MAJ---
ThisWorkbook.Names.Add "Memo", a 'nom défini
Application.EnableEvents = False 'désactive les évènements
P.Rows(2) = Application.Index(a, 2, 0)
Application.EnableEvents = True 'réactive les évènements
End Sub