Citation :
Sub main() Dim i As Integer, j As Integer Dim sheet1_name As String, sheet2_name As String, sheet3_name As String, name As String Dim delete As Boolean sheet1_name = "Feuil1" sheet2_name = "Feuil2" sheet3_name = "Feuil3" 'stock name sheet1 in sheet3 col1 With ThisWorkbook.Worksheets(sheet1_name) For i = 1 To .Cells(1, 1).End(xlDown).Row ThisWorkbook.Worksheets(sheet3_name).Cells(i, 1).Value = .Cells(i, 1).Value Next i End With 'stock name sheet2 in sheet3 col2 With ThisWorkbook.Worksheets(sheet2_name) For i = 1 To .Cells(1, 1).End(xlDown).Row ThisWorkbook.Worksheets(sheet3_name).Cells(i, 2).Value = .Cells(i, 1).Value Next i End With 'delete sheet1 With ThisWorkbook.Worksheets(sheet1_name) For i = .Cells(1, 1).End(xlDown).Row To 1 Step -1 name = .Cells(i, 1).Value delete = False With ThisWorkbook.Worksheets(sheet3_name) For j = .Cells(1, 2).End(xlDown).Row To 1 Step -1 If name = .Cells(j, 2).Value Then delete = True Exit For End If Next j End With If delete = True Then .Rows(i).delete Next i End With 'delete sheet2 With ThisWorkbook.Worksheets(sheet2_name) For i = .Cells(1, 1).End(xlDown).Row To 1 Step -1 name = .Cells(i, 1).Value delete = False With ThisWorkbook.Worksheets(sheet3_name) For j = .Cells(1, 1).End(xlDown).Row To 1 Step -1 If name = .Cells(j, 1).Value Then delete = True Exit For End If Next j End With If delete = True Then .Rows(i).delete Next i End With End Sub
|