Private Sub Workbook_Open()
Dim Cel As Range, Dte As Date, p As Range, za As Range, ExistZa As Boolean
Dte = Sheets("y").Range("E2").Value
Application.ScreenUpdating = False
With Sheets("x")
Set p = .Range("C12:C" & Rows.Count).SpecialCells(xlCellTypeConstants)
For Each Cel In p
Cel.Resize(, 11).Font.Bold = (Cel.Value < Dte)
If Cel.Font.Bold Then
If za Is Nothing Then
Set za = Cel.Resize(, 11)
Else
Set za = Application.Union(za, Cel.Resize(, 11))
End If
End If
Next
End With
Application.ScreenUpdating = True
For Each nom In ActiveWorkbook.Names
If nom.Name = "za" Then
ExistZa = True
Exit For
End If
Next
' Si la plage nommée "za" n'existe pas, elle est créée en cellule A1, pour éviter une erreur,
' puis renommée dans les lignes suivantes
If ExistZa = False Then ActiveWorkbook.Names.Add Name:="za", RefersToR1C1:="=x!R1C1"
With ActiveWorkbook.Names("za")
' Modification de la plage nommée "za" en fonction de la nouvelle valeur
.Name = "za"
.RefersToR1C1 = za
za.Range("A1").Activate ' Active la cellule en haut et à gauche de la plage "za"
End With
End Sub