Option Explicit
Private Sub Maj_Abs()
'définition des variables
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim debmois As Date
Dim finmois As Date
Dim mois As Long
Dim annee As Long
Dim x As Variant
Dim i As Variant
Dim s As Integer
Dim y As Variant
Dim c As Variant
'définition des références de variable
Set ws1 = Sheets("Récapitulatif")
Set ws2 = Sheets("Absences")
debmois = DateSerial(annee, mois, 1)
finmois = DateSerial(annee, mois + 1, 1)
'boucle de recherche
For Each c In ws1.Range("a2:a" & ws1.[a200].End(xlDown).Row)
x = Cells.Value
Do While Cells(i, 1).Value = ""
i = i + 1
For Each x In ws2.Range("a2:a" & ws2.[a200].End(xlDown).Row)
If Cells(i, 8).Value = ws1.Cells(1, 6).Value And Cells(i, 9).Value = ws1.Cells(1, 6).Value Then
s = s + Cells(i, 10).Value
ElseIf Cells(i, 8).Value = ws1.Cells(1, 6).Value And Cells(i, 9).Value <> ws1.Cells(1, 6).Value Then
y = WorksheetFunction.Int(finmois - (Cells(i, 3).Value + Cells(i, 4).Value))
s = s + y
ElseIf Cells(i, 8).Value <> ws1.Cells(1, 6).Value And Cells(i, 9) = ws1.Cells(1, 6).Value Then
y = WorksheetFunction.Int(debmois - (Cells(i, 5).Value + Cells(i, 6).Value))
s = s + y
End If
Cells.Range(x, 3).Value = s
Next x
Loop
Next c
End Sub