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 37 38 39 40 41 42 43 44 45
| Option Explicit
Dim i, d, v, Val_f1, Date_f1, Pos1
Dim f1 As Worksheet, f2 As Worksheet
Dim Val_Col3, Val_Col6
Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
'Déclaration des variables
Set f1 = Sheets("Plan d'Actions")
Set f2 = Sheets("Planning")
'Sélection de la cellule intersect
If Not Intersect(Target, Range("$R6:$R177")) Is Nothing Then
Val_f1 = f1.Cells(Target.Row, "O")
Date_f1 = f1.Cells(Target.Row, "S")
Val_Col3 = f1.Cells(Target.Row, "C")
Val_Col6 = f1.Cells(Target.Row, "F")
Recherche
End If
Set v = Nothing
Set d = Nothing
Set f1 = Nothing
Set f2 = Nothing
End Sub
Sub Recherche()
f2.Select
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.Cells(v.Row, d.Column) = Val_Col3 & " " & Format(Val_Col6, "hh:mm")
Exit Sub
End If
Set v = .FindNext(v)
Loop While v <> "" And v.Address <> Pos1
End If
End With
End Sub |
Partager