Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
DerLig = Sheets("Journal").ListObjects("Tableau1").DataBodyRange.Rows.Count
piece = Range("F7").Value
For i = 10 To DerLig
If Cells(i, "C") = piece Then
Range(Cells(i, "B"), Cells(i, "G")).Copy Cells(DerLig + 10, "B")
Cells(DerLig + 10, "C") = piece
Cells(DerLig + 10, "J") = "Ext. " & Cells(i, "J")
Cells(DerLig + 10, "K") = Cells(i, "L")
Cells(DerLig + 10, "L") = Cells(i, "K")
Cells(DerLig + 10, "Q") = Cells(i, "Q")
DerLig = Sheets("Journal").ListObjects("Tableau1").DataBodyRange.Rows.Count
End If
Next i
End Sub
Private Sub CommandButton1_Click()
Dim ta(), tb(), derligne&, i&, j&, m&
'-- paramétrage
derligne = Cells(Rows.Count, 3).End(3).Row
ta = Range("B10:Q" & derligne).Value
ReDim tb(1 To derligne - 9, 1 To 16)
m = 0
'--boucle tableau
For i = 1 To derligne - 9
If ta(i, 2) = Cells(7, "F") Then
m = m + 1
'-- pour les cellules sans modification
A = Array(1, 2, 3, 4, 5, 6, 7, 8, 12, 13, 14, 15, 16)
For j = LBound(A) To UBound(A)
tb(m, A(j)) = ta(i, A(j))
Next j
'-- pour les autres cellules
tb(m, 9) = "Ext. " & ta(i, 9)
tb(m, 10) = IIf(ta(i, 11) = "", "", ta(i, 11))
tb(m, 11) = IIf(ta(i, 10) = "", "", ta(i, 10))
End If
Next i
'-- restitution
Range("B" & (derligne + 1)).Resize(m, 16) = tb
End Sub
tb(m, 3) = IIf(m = 1, "X", " ")