Sub Chercher()
Dim Fe_Ref As Worksheet
Dim Fe_Supprim As Worksheet
Dim Plage_Ref As Range
Dim Plage_Supprim As Range
Dim Cel_Ref As Range
Dim Cel_Supprim As Range
Dim Tbl() As Long
Dim I As Long
'feuille où se trouve les entreprises de référence
Set Fe_Ref = Worksheets("Feuil1")
'feuille où se trouve les entreprises qui seront supprimées
Set Fe_Supprim = Worksheets("Feuil2")
'nom des entreprise en colonne A
With Fe_Ref
Set Plage_Ref = .Range(.Cells(1, 1), .Cells(.Rows.Count, 1).End(xlUp))
End With
'idem
With Fe_Supprim
Set Plage_Supprim = .Range(.Cells(1, 1), .Cells(.Rows.Count, 1).End(xlUp))
End With
'on suppose que l'entreprise n'existe qu'une fois dans la feuille
'on parcour la plage où doivent être supprimées les entreprises
'si pas trouvée, on mémorise la ligne dans un tableau
For Each Cel_Supprim In Plage_Supprim
Set Cel_Ref = Plage_Ref.Find(Cel_Supprim, , xlValues, xlWhole)
If Cel_Ref Is Nothing Then
I = I + 1
ReDim Preserve Tbl(1 To I)
Tbl(I) = Cel_Supprim.Row
End If
Next Cel_Supprim
'pour une suppression par le bas de la feuille
'on tri le tableau en ordre décroissant
Tri Tbl()
'on supprime les lignes
For I = 1 To UBound(Tbl)
Fe_Supprim.Rows(Tbl(I)).EntireRow.Delete
Next I
End Sub
Sub Tri(Tbl() As Long)
Dim Tempo
Dim I As Long
Dim J As Long
'pour un tri décroissant "<"
'pour un tri croissant ">"
For I = 1 To UBound(Tbl) - 1
For J = I + 1 To UBound(Tbl)
If Tbl(I) < Tbl(J) Then
Tempo = Tbl(J)
Tbl(J) = Tbl(I)
Tbl(I) = Tempo
End If
Next J
Next I
End Sub