Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False 'évite de raffraîchir continuellement
If Intersect(Target, [NoProduit]) Is Nothing Then Exit Sub
If Not Intersect(Target, [NoProduit]) Is Nothing And [NoProduit] <> "" Then
Sheets("Consultation").Range("A7:O20000").ClearContents 'Vider le tableau de résultats
With ThisWorkbook.Sheets("Table").Range("A1:O20000") 'plage de recherche
Set Produit_Cherché = .Find([NoProduit], lookat:=xlWhole)
If Not Produit_Cherché Is Nothing Then
firstAddress = Produit_Cherché.Address
Do
Lastrow = ThisWorkbook.Sheets("Consultation").Range("A60000").End(xlUp).Row + 1 'ligne où écrire
Sheets("Table").Range("A" & Produit_Cherché.Row & ":O" & Produit_Cherché.Row).Copy Destination:=Sheets("Consultation").Range("A" & Lastrow) 'copie de la ligne
Set Produit_Cherché = .FindNext(Produit_Cherché)
Loop While Not Produit_Cherché Is Nothing And Produit_Cherché.Address <> firstAddress
End If
End With
End If
If Not Intersect(Target, [NoProduit]) Is Nothing And [NoProduit] = "" Then Sheets("Consultation").Range("A7:O20000").ClearContents 'Vider le tableau de résultats si C3 est vide
Application.ScreenUpdating = True
End Sub