1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| Option Explicit
Sub recherche()
Dim f1 As Worksheet, f2 As Worksheet
Dim v As Object, d As Object
Dim i As Long
Dim Val_f1 As String, Pos1 As String
Dim Date_f1 As Date
Set f1 = Sheets("Feuil1")
Set f2 = Sheets("Feuil2")
For i = 6 To 177
Val_f1 = f1.Cells(i, "O")
Date_f1 = f1.Cells(i, "S")
With f2.Range("A5:A120")
Set v = .Find(Val_f1, LookIn:=xlValues, lookat:=xlWhole)
If Not v Is Nothing Then
Pos1 = v.Address
Do
Set d = f2.Range("B4:EG4").Find(Date_f1, LookIn:=xlFormulas, lookat:=xlWhole)
If Not d Is Nothing Then
f2.Select
Cells(v.Row, d.Column).Select
Exit Sub
End If
Set v = .FindNext(v)
Loop While v Is Nothing And v.Address <> Pos1
End If
End With
Next i
Set v = Nothing
Set d = Nothing
Set f1 = Nothing
Set f2 = Nothing
End Sub |
Partager