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
| Option Explicit
Sub Test()
Dim Cptdate As Byte
Dim CptList As Integer
Dim Tmp As String, PlageCalDev As String, PlageCalDate As String
Dim Dates(0 To 1) As Long
Dim ShtList As Worksheet, ShtCal As Worksheet
Application.ScreenUpdating = False
Set ShtList = Sheets("List")
Set ShtCal = Sheets("Calendar")
PlageCalDev = "'" & ShtCal.Name & "'!$A2:$A" & ShtCal.Range("A" & ShtCal.Rows.Count).End(xlUp).Row
PlageCalDate = "'" & ShtCal.Name & "'!$C2:$C" & ShtCal.Range("A" & ShtCal.Rows.Count).End(xlUp).Row
For CptList = 1 To ShtList.Range("A" & ShtList.Rows.Count).End(xlUp).Row
Tmp = ShtList.Range("E" & CptList).Value
Dates(0) = CLng("20" & Right(Tmp, 2) & Mid(Tmp, 3, 2) & Left(Tmp, 2))
Tmp = ShtList.Range("G" & CptList).Value
Dates(1) = CLng("20" & Right(Tmp, 2) & Mid(Tmp, 3, 2) & Left(Tmp, 2))
For Cptdate = 0 To 1
While Evaluate("SumProduct((" & PlageCalDev & "=" & Chr(34) & ShtList.Range("A" & CptList).Value & Chr(34) & ")*(" & PlageCalDate & "=" & Dates(Cptdate) & ")*1)") <> 0
Tmp = CStr(Dates(Cptdate))
Tmp = CStr(DateValue(Right(Tmp, 2) & "/" & Mid(Tmp, 5, 2) & "/" & Left(Tmp, 4)) + 1)
Dates(Cptdate) = CLng(Right(Tmp, 4) & Mid(Tmp, 4, 2) & Left(Tmp, 2))
Wend
Tmp = CStr(Dates(Cptdate))
ShtList.Range("E" & CptList & ":F" & CptList).Offset(, Cptdate * 2).Value = CLng(Right(Tmp, 2) & Mid(Tmp, 5, 2) & Mid(Tmp, 3, 2))
Next Cptdate
Next CptList
Set ShtList = Nothing
Set ShtCal = Nothing
Application.ScreenUpdating = True
End Sub |
Partager