Option Explicit
Private Sub Worksheet_Activate()
Dim Cel As Range, Dt As Date, RngUnion As Range
For Each Cel In PlageÀPartirDe(Me.Cells(4, 3))
If VarType(Cel.Value) = vbDate Then
Dt = Cel.Value
If Dt < Date Then
Cel.Font.Color = &HFF&
MsgBox Cel.Address(False, False) & " = " & Dt & ", vieux de " _
& Date - Dt & " jours", vbInformation, Me.Name
If RngUnion Is Nothing Then Set RngUnion = Cel Else Set RngUnion = Union(RngUnion, Cel)
End If
End If
Next Cel
Application.Goto RngUnion
End Sub
Private Function PlageÀPartirDe(ByVal CelDéb As Range) As Range
Rem. ——— Plage utilisée à partir de CelDéb.
Dim NbrLig As Long, NBrCol As Long
With CelDéb.Worksheet.UsedRange:
NbrLig = .Row + .Rows.Count - CelDéb.Row
NBrCol = .Column + .Columns.Count - CelDéb.Column
If NbrLig <= 0 Or NBrCol <= 0 Then Exit Function
End With
Set PlageÀPartirDe = CelDéb.Resize(NbrLig, NBrCol)
End Function