Sub Comparaison()
Range("D2").Select
Dim rListOne As Range, rListTwo As Range, curCell As Range
Dim nbErr As Integer
Application.ScreenUpdating = False
'on travaille avec la "Feuil1"
With ThisWorkbook.Sheets("Feuil1")
'"rListOne" = "Feuil1!D2D<dernièreLigne>"
Set rListOne = .Range("D2:D" & .Range("D" & .Rows.Count).End(xlUp).Row)
Set rListTwo = .Range("A2:A" & .Range("A" & .Rows.Count).End(xlUp).Row)
'boucler sur chaque élément de rListTwo
For Each curCell In rListTwo.Cells
'si on ne trouve pas l'équivalent dans rListOne
If rListOne.Find(curCell, , xlValues, xlWhole) Is Nothing Then
'colorer la cellule
curCell.Resize(1, 2).Interior.Color = RGB(255, 0, 0)
curCell.Offset(0, 1).Value = "ERREUR"
nbErr = nbErr + 1
Else
curCell.Resize(1, 2).Interior.Color = xlNone
End If
Next curCell
'filtrer sur les erreurs
.Range("B1").AutoFilter Field:=2, Criteria1:="ERREUR"
Application.ScreenUpdating = True
If nbErr = 0 Then
Call MsgBox(" AUCUNE erreur détectée ", vbInformation, "Pour info. . .")
.ShowAllData
Else
'Compte les nombre de fiche inox sans date après filtrage
Call MsgBox(" " & nbErr & " ERREURS détectées " & Chr(13) & " Veuilez les corriger ", vbCritical, " Attention !")
End If
End With
End Sub
Sub Montrer_Tout()
On Error Resume Next
With ThisWorkbook.Sheets("Feuil1")
.ShowAllData
.Range(.Cells(2, 1), .Cells(2, 1).End(xlDown).Offset(0, 1)).Interior.Color = xlNone
.Range(.Cells(2, 1), .Cells(2, 1).End(xlDown)).Offset(0, 1).Clear
End With
End Sub