Public Sub RXlibre()
Dim ListeRX As Variant, ListePLANNING As Range, ListeAbsent() As String
Dim j As Integer, i As Integer, k As Integer, Cel As Range, List
Dim lign
lign = Application.InputBox("Entrez un N° de ligne compris entre 5 et 39", "Choix de la ligne", Type:=1)
If lign = 0 Then Exit Sub
If lign < 5 Or lign > 39 Then
MsgBox "Saisir un nombre entre 5 et 39.", vbCritical, "Attention:"
Exit Sub
End If
With Sheets("RX")
ListeRX = .Range("E6:E" & .Range("E65536").End(xlUp).Row)
End With
With Sheets("PLANNING")
Set ListePLANNING = .Range("C" & lign & ":" & "W" & lign)
End With
For i = LBound(ListeRX) To UBound(ListeRX)
Set Cel = ListePLANNING.Find(ListeRX(i, 1))
If Cel Is Nothing Then
ReDim Preserve ListeAbsent(j)
ListeAbsent(j) = ListeRX(i, 1)
j = j + 1
End If
Next i
On Error GoTo fin
For k = LBound(ListeAbsent) To UBound(ListeAbsent)
List = List & ListeAbsent(k) & vbCrLf
Next
MsgBox "Les agents suivants ne travaillent pas :" & vbCrLf & vbCrLf & List
Exit Sub
fin:
If Err = 9 Then MsgBox " Tout le monde travaille"
End Sub