1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| Sub test()
Dim i As Integer, j As Integer, x As Integer, Er As String
x = Sheets.Count
Er = ""
With Sheets("Données")
For i = 2 To .Cells(Rows.Count, 1).End(xlUp).Row
If .Cells(i, 3) <> "X" Then
For j = 2 To x
If .Cells(i, 2) = UCase(Sheets(j).Name) Then
.Range(.Cells(i, 1), .Cells(i, 2)).Copy Sheets(j).Cells(Rows.Count, 1).End(xlUp)(2)
.Cells(i, 3) = "X"
Exit For
End If
Next j
End If
If .Cells(i, 3) <> "X" Then Er = Er & Chr(10) & .Cells(i, 1) & "/" & .Cells(i, 2)
Next i
End With
If Er <> "" Then
MsgBox "les articles suivants n'ont pas été copié :" & Chr(10) & Er
Else
MsgBox "tous les articles ont été copié"
End If
End Sub |
Partager