Private Sub Worksheet_Change(ByVal Target As Range)
Dim dates As Range, ville As Range, r As Range, lettre$, i%, deb As Variant, fin As Variant
Set dates = Range(Rows(4).Find("*", , xlValues), Cells(4, Columns.Count)) 'dates en ligne 4
Application.ScreenUpdating = False
Application.EnableEvents = False 'désactive les évènement
For Each ville In Rows(1).SpecialCells(xlCellTypeConstants, 2)
If ville <> "" And ville.Column > 1 And ville.MergeCells Then
Set r = Intersect(Target.EntireRow, ville.MergeArea.EntireColumn, UsedRange)
If Not r Is Nothing Then
lettre = UCase(Left(ville, 1)) 'initiale du nom
For Each r In r.Rows
If r.Row > 7 Then 'à partir de la ligne 8
Intersect(r.EntireRow, dates.EntireColumn).Replace lettre, "", xlWhole, MatchCase:=False 'RAZ
For i = 1 To r.Cells.Count - 1 Step 2
If IsDate(r.Cells(i)) And IsDate(r.Cells(i + 1)) Then
deb = Application.Match(r.Cells(i).Value2, dates)
fin = Application.Match(r.Cells(i + 1).Value2, dates)
If IsNumeric(deb) And IsNumeric(fin) Then
With Intersect(r.EntireRow, Range(dates(deb), dates(fin)).EntireColumn)
.Value = lettre
.Font.Bold = True 'gras
.Font.Color = IIf(lettre = "M", vbBlue, IIf(lettre = "L", vbGreen, vbRed))
End With
End If
End If
Next i
End If
Next r
End If
End If
Next ville
Application.EnableEvents = True 'réactive les évènement
End Sub