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
| Sub FillRosterSA()
Dim sht, targetsht As Worksheet
rotaNLAM = 3
rotaNLPM = 8
For j = 2 To LastRow
'Saturday
If Right(sht.Cells(j, 6).Value, 1) = "A" Then
'AM
If sht.Cells(j, 3).Value <= sht.Cells(4, 1).Value Then
targetsht.Cells(rotaNLAM + 1, 10).Value = sht.Cells(j, 3).Value
targetsht.Cells(rotaNLAM + 2, 10).Value = sht.Cells(j, 4).Value
twelvehourscond = targetsht.Cells(rotaNLAM + 1, 10).Value
fortyminCond = targetsht.Cells(rotaNLAM + 2, 10).Value
rotaNLAM = rotaNLAM + 11
End If
'PM
If sht.Cells(j, 3).Value - fortyminCond > sht.Cells(3, 1).Value And sht.Cells(j, 4).Value - twelvehourscond <= sht.Cells(5, 1).Value Then
targetsht.Cells(rotaNLPM, 10).Value = sht.Cells(j, 12).Value
rotaNLPM = rotaNLPM + 11
End If
End If
Next
End Sub |
Partager