Private Sub CommandButton1_Click()
Dim wkA As Workbook, wkB As Workbook
Dim x As Long, Tmp&
Dim j As Long
Dim h As Long
Application.ScreenUpdating = False
Set wkA = ActiveWorkbook ' classeur d arrivee
Set wkB = Workbooks("Classeur données.xlsx") ' classeur de donn?e
h = wkA.Worksheets("Feuil1").Cells.Find("*", , , , xlByRows, xlPrevious).Row
With wkB.Worksheets("relance completude")
x = .Cells.Find("*", , , , xlByRows, xlPrevious).Row
For j = 2 To x
If LCase(.Cells(j, 1)) = "ok" Then
If IsError(Application.Match(.Cells(j, 3).Value, wkA.Worksheets("Feuil1").[b:b], 0)) Then
h = h + 1
wkA.Worksheets("Feuil1").Cells(h, 1).Value = .Cells(j, 2).Value 'nom du projet
wkA.Worksheets("Feuil1").Cells(h, 2).Value = .Cells(j, 3).Value ' affaire mere
wkA.Worksheets("Feuil1").Cells(h, 3).Value = .Cells(j, 4).Value ' nom affaire colonne 1
wkA.Worksheets("Feuil1").Cells(h, 4).Value = .Cells(j, 5).Value ' commune
Else ' si modification et ok
If IsNumeric(Application.Match(.Cells(j, 3).Value, wkA.Worksheets("Feuil1").[b:b], 0)) Then
Tmp = Application.Match(.Cells(j, 3).Value, wkA.Worksheets("Feuil1").[b:b], 0)
wkA.Worksheets("Feuil1").Cells(Tmp, 1).Value = .Cells(j, 2).Value 'nom du projet
wkA.Worksheets("Feuil1").Cells(Tmp, 2).Value = .Cells(j, 3).Value ' affaire mere
wkA.Worksheets("Feuil1").Cells(Tmp, 3).Value = .Cells(j, 4).Value ' nom affaire colonne 1
wkA.Worksheets("Feuil1").Cells(Tmp, 4).Value = .Cells(j, 5).Value ' commune
End If
End If
Else ' si ok supprimer
If IsNumeric(Application.Match(.Cells(j, 3).Value, wkA.Worksheets("Feuil1").[b:b], 0)) Then
Rows(Application.Match(.Cells(j, 3).Value, wkA.Worksheets("Feuil1").[b:b], 0)).Delete
End If
End If
Next j
End With
End Sub