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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
Sub test()
Dim nb_ligne As Integer
Dim I As Long
Dim LaDate As Date
With Worksheets("feuille d'heures mensuel 1")
With .Range("C19:K49").Interior
.ThemeColor = xlThemeColorDark1
End With
'effacer le contenu des cellules avant de cmmencer une nouvelle génération
.Range("C19:K49").ClearContents
'supprime les fusions pécédentes si existes...
.Range("C19:K49").UnMerge
'calcule le nombre de jours dans le mois
'Attention, il faut revoir les formules car le max de jours toujours égal à 30 ???
LaDate = CDate("01/" & Cells(16, 2) & "/" & Right(Cells(16, 3), 4))
nb_ligne = Day(DateSerial(Year(LaDate), Month(LaDate) + 1, 1) - 1)
'heure d'arrivée
.Cells(19, 3) = .Cells(14, 7)
.Cells(19, 3).AutoFill .Range(.Cells(19, 3), .Cells(nb_ligne + 18, 3)) 'étend à la plage...
'heure de départ
.Cells(19, 8) = .Cells(15, 7)
.Cells(19, 8).AutoFill .Range(.Cells(19, 8), .Cells(nb_ligne + 18, 8)) 'étend à la plage...
'delta
.Cells(19, 10).Formula = "=IF(" & .Cells(19, 3).Address(0, 0) & ">" & .Cells(19, 8).Address(0, 0) & ",1-" _
& .Cells(19, 3).Address(0, 0) & "+" & .Cells(19, 8).Address(0, 0) & "," _
& .Cells(19, 8).Address(0, 0) & "-" & .Cells(19, 3).Address(0, 0) & ")"
.Cells(19, 10).AutoFill .Range(.Cells(19, 10), .Cells(nb_ligne + 18, 10)) 'étend à la plage...
' Jours de repos
For I = 0 To nb_ligne
If .Cells(19 + I, 1).Text = .Cells(16, 7) Then
.Cells(19 + I, 3) = "repos"
.Cells(19 + I, 8) = ""
.Cells(19 + I, 10) = ""
Range(.Cells(19 + I, 3), .Cells(19 + I, 11)).Merge
With .Range(.Cells(19 + I, 3), .Cells(19 + I, 11)).Interior
.ThemeColor = xlThemeColorDark1
.TintAndShade = -0.349986266670736
End With
End If
Next I
End With
End Sub |
Partager