Sub Copie_Non_Livre()
Application.ScreenUpdating = False
Dim CMD As Worksheet, TDB As Worksheet, DerligSrc&, DerligDst&, i&, NB&
Set CMD = Worksheets("COMMANDES")
Set TDB = Worksheets("Tableau de bord")
With CMD
DerligSrc = .Range("B" & Rows.Count).End(xlUp).Row
DerligDst = TDB.Range("A" & Rows.Count).End(xlUp).Row + 1
[A8] = 1: .Range("A8:A" & DerligSrc).DataSeries
.Range("A8:O" & DerligSrc).Sort Key1:=.Range("O8:O" & DerligSrc), Order1:=2, Header:=xlNo
NB = WorksheetFunction.CountIf(.Range("O8:O65500"), "Non livré") - 1
TDB.Range("B" & DerligDst - n & ":M" & DerligDst + NB) = .Range("D8:O" & 8 + NB).Value
TDB.Range("A" & DerligDst - n & ":A" & DerligDst + NB) = .Range("B8:B" & 8 + NB).Value
.Range("A8:O" & DerligSrc).Sort Key1:=.Range("A8:A" & DerligSrc), Order1:=1, Header:=xlNo
.Range("A8:A" & DerligSrc).ClearContents
End With
Set CMD = Nothing: Set TDB = Nothing
End Sub
Private Sub CommandButton1_Click()
Copie_Non_Livre
End Sub