Public Tbill, Tgates: Option Base 1
Sub ListeAbsent()
Dim i%, j%, k%, Ligne%, n%
Dim T(): ReDim Preserve T(12, 1): n = 1
Sheets("Absents").[A:L].ClearContents
Sheets("Absents").Range("A1:L1") = Sheets("Bill").Range("A1:L1").Value ' Copier Coller entete
Sheets("Absents").Range("L1") = "Absent dans"
Application.ScreenUpdating = False
' Transfert des deux tableaux dans Absents
DL1 = Sheets("Bill").[A65000].End(xlUp).Row
Tbill = Sheets("Bill").Range("A2:L" & DL1).Value
DL2 = Sheets("Gates").[A65000].End(xlUp).Row
Tgates = Sheets("Gates").Range("A1:L" & DL2).Value
Ligne = 2
' Absent dans Gates
For i = 1 To UBound(Tbill)
If Present(Tgates, Tbill(i, 4)) = 0 Then ' si 0 alors absent, donc transfert
For k = 1 To 11
T(k, n) = Tgates(i, k)
Next k
T(12, n) = "Gates"
Ligne = Ligne + 1: n = n + 1
ReDim Preserve T(12, n)
End If
Next i
' Absent dans Bill
For i = 1 To UBound(Tgates)
If Present(Tbill, Tgates(i, 4)) = 0 Then
For k = 1 To 11
T(k, n) = Tgates(i, k)
Next k
T(12, n) = "Bill"
Ligne = Ligne + 1: n = n + 1
ReDim Preserve T(12, n)
End If
Next i
Sheets("Absents").[A2].Resize(UBound(T, 2), UBound(T, 1)) = WorksheetFunction.Transpose(T)
Application.ScreenUpdating = True
End Sub
Function Present(Plage, Valeur)
' Present retourne 0 si absent et 1 si présent
Present = 0
For Ind = 1 To UBound(Plage)
If Plage(Ind, 4) = Valeur Then
Present = 1
Exit Function
End If
Next Ind
End Function