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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
| Public Function sommecollab(matricule As Variant, sem As Variant, choix As Byte) As Variant
Dim dico, ListeCle, ListeElement, Tempo1, Tempo2
Dim c As Range
Dim cumul As Double
Dim datedéb, datefin
Dim i As Byte, j As Byte
Application.ScreenUpdating = False
'--------------------------------------------------------------------------------CALCUL DU DEBUT D'ABSENCE ET DU CUMUL DES HEURES----------------------------------------------------------------------------
cumul = 0
Set dico = CreateObject("Scripting.Dictionary")
For Each c In plage
If c = matricule And c.Offset(0, 6) = sem Then
cumul = cumul + c.Offset(0, 5)
If Not dico.Exists(c.Offset(0, -5).Value) Then dico.Add c.Offset(0, -5).Value, c.Value
End If
Next c
ListeCle = dico.Keys
ListeElement = dico.Items
If dico.Count >= 2 Then
'tri dico
For i = 0 To dico.Count - 2
For j = i + 1 To dico.Count - 1
If ListeCle(i) > ListeCle(j) Then
Tempo1 = ListeCle(j)
Tempo2 = ListeCle(j)
ListeElement(j) = ListeElement(i)
ListeElement(j) = ListeElement(i)
ListeElement(i) = Tempo1
ListeCle(i) = Tempo2
End If
Next j
Next i
End If
datedéb = ListeCle(0)
Set dico = Nothing
'--------------------------------------------------------------------------------CALCUL FIN D'ABSENCE----------------------------------------------------------------------------
Set dico = CreateObject("Scripting.Dictionary")
For Each c In plage
If c = matricule And c.Offset(0, 6) = sem Then _
If Not dico.Exists(c.Offset(0, -4).Value) Then dico.Add c.Offset(0, -4).Value, c.Value
Next c
ListeCle = dico.Keys
ListeElement = dico.Items
If dico.Count >= 2 Then
'tri dico
For i = 0 To dico.Count - 2
For j = i + 1 To dico.Count - 1
If ListeCle(i) > ListeCle(j) Then
Tempo1 = ListeCle(j)
Tempo2 = ListeCle(j)
ListeElement(j) = ListeElement(i)
ListeElement(j) = ListeElement(i)
ListeElement(i) = Tempo1
ListeCle(i) = Tempo2
End If
Next j
Next i
End If
datefin = ListeCle(dico.Count - 1)
Select Case choix
Case 1
sommecollab = datedéb
Case 2
sommecollab = datefin
Case 3
sommecollab = cumul
End Select
End Function |
Partager