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
| Sub update()
Dim cell_ori As Range
Dim cell_des As Range
Dim dte As Date
Dim report As String
'Place le chemin de ton classeur4
report = "C:\Users\...\Desktop\Classeur4.xls"
For Each Wb In Workbooks
If Wb.FullName Like report Then
Wb.Activate
Exit For
End If
Next Wb
If Wb Is Nothing Then
Workbooks.Open Filename:=report
End If
With Workbooks("Classeur3").Worksheets("BASE")
For i = 0 To 4
For j = 0 To 6
Set cell_ori = .Range("D3").Offset(i * 6, j)
dte = cell_ori.Value
If dte <> "00:00:00" Then
Set cell_des = Workbooks("Classeur4").Worksheets("Feuil1").Columns(3).Find(dte, LookIn:=xlFormulas, lookat:=xlWhole)
If Not cell_des Is Nothing Then
For k = 1 To 4
cell_des.Offset(0, 3 + k) = cell_ori.Offset(k, 0)
Next k
For k = 0 To 2
cell_des.Offset(0, k + 1) = cell_ori.Offset(k * 2, 10)
Next k
End If
End If
Next j
Next i
End With
End Sub |
Partager