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
| Sub controle_effectif()
Dim i As Integer
Dim j As Integer
Dim finrh As Integer
Dim fincascade As Integer
Dim caractere As Integer
Dim finlist As Integer
Dim anomalie As Boolean
finrh = Sheets("rh").Range("B" & Rows.Count).End(xlUp).Row
fincascade = Sheets("cascade").Range("B" & Rows.Count).End(xlUp).Row
For i = 3 To finrh
caractere = Len(Sheets("rh").Range("D" & i))
For j = 2 To fincascade
If (Sheets("rh").Range("D" & i) = Right(Sheets("cascade").Range("A" & j), caractere) And caractere <> 0) Then
anomalie = False
Exit For
End If
If (Sheets("rh").Range("D" & i) <> Right(Sheets("cascade").Range("A" & j), caractere) And caractere <> 0) Then
anomalie = True
End If
If (caractere = 0) Then
finlist = Sheets("controle effectif").Range("A" & Rows.Count).End(xlUp).Row + 1
Sheets("controle effectif").Range("A" & finlist) = Sheets("rh").Range("F" & i) & " " & "Matricule manquant"
Exit For
End If
Next
If (anomalie = True) Then
finlist = Sheets("controle effectif").Range("A" & Rows.Count).End(xlUp).Row + 1
Sheets("controle effectif").Range("A" & finlist) = Sheets("rh").Range("F" & i)
End If
Next
End Sub |
Partager