Sub Sched_Forward()
Dim i As Integer
i = 2
Columns("AB:AB").NumberFormat = "dd/mm/yyyy"
Do
If (Cells(i, 28) = "") And Cells(i, 23) = "OSP" And DiffDate(Cells(i - 1, 28), DateAdd("d", 7, Cells(i - 1, 28)), 5) = 7 Then
Cells(i, 28) = DateAdd("d", 7, Cells(i - 1, 28))
End If
If (Cells(i, 28) = "") And Cells(i, 23) = "OSP" And DiffDate(Cells(i - 1, 28), DateAdd("d", 8, Cells(i - 1, 28)), 5) = 7 Then
Cells(i, 28) = DateAdd("d", 8, Cells(i - 1, 28))
End If
If (Cells(i, 28) = "") And Cells(i, 23) = "OSP" And DiffDate(Cells(i - 1, 28), DateAdd("d", 9, Cells(i - 1, 28)), 5) = 7 Then
Cells(i, 28) = DateAdd("d", 9, Cells(i - 1, 28))
End If
If (Cells(i, 28) = "") And Cells(i, 23) = "OSP" And DiffDate(Cells(i - 1, 28), DateAdd("d", 10, Cells(i - 1, 28)), 5) = 7 Then
Cells(i, 28) = DateAdd("d", 10, Cells(i - 1, 28))
End If
If (Cells(i, 28) = "") And DiffDate(Cells(i - 1, 28), DateAdd("d", 1, Cells(i - 1, 28)), 5) = 1 Then
Cells(i, 28) = DateAdd("d", 1, Cells(i - 1, 28))
End If
If (Cells(i, 28) = "") And DiffDate(Cells(i - 1, 28), DateAdd("d", 2, Cells(i - 1, 28)), 5) = 1 Then
Cells(i, 28) = DateAdd("d", 2, Cells(i - 1, 28))
End If
If (Cells(i, 28) = "") And DiffDate(Cells(i - 1, 28), DateAdd("d", 3, Cells(i - 1, 28)), 5) = 1 Then
Cells(i, 28) = DateAdd("d", 3, Cells(i - 1, 28))
End If
If (Cells(i, 28) = "") And DiffDate(Cells(i - 1, 28), DateAdd("d", 4, Cells(i - 1, 28)), 5) = 1 Then
Cells(i, 28) = DateAdd("d", 4, Cells(i - 1, 28))
End If
If (Cells(i, 28) = "") And DiffDate(Cells(i - 1, 28), DateAdd("d", 5, Cells(i - 1, 28)), 5) = 1 Then
Cells(i, 28) = DateAdd("d", 5, Cells(i - 1, 28))
End If
i = i + 1
Loop Until IsEmpty(Cells(i, 12)) = True
End Sub |