1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| Dim Plage As Range, Dt As Range, c As Range
Dim Resultat As Date
With Sheets(1)
Set Plage = .Range("A20", .Range("A" & .Rows.Count).End(xlUp))
End With
Set Dt = Sheets(2).Range("A1")
If Dt.Value < Application.Min(Plage) Then
Set c = Plage(1)
ElseIf Dt.Value >= Application.Max(Plage) Then
Set c = Plage(Plage.Rows.Count)
Else
Resultat = Evaluate("=VLookup(" & Dt.Address & "," & "Feuil1!" & Plage.Address & ", 1, True)")
Set c = Plage.Find(Resultat)
If DateDiff("d", c.Value, Dt.Value) > DateDiff("d", Dt.Value, c.Offset(1, 0).Value) Then Set c = c.Offset(1, 0)
End If
Set Plage = Nothing
Resultat = c.Value
MsgBox "Valeur proche trouvée de " & Dt.Value & " est " & Resultat & " trouvé en " & c.Address
Set Dt = Nothing
Set c = Nothing |