Sub ajout_suivi_geste_co()
Dim tablo, resu(), i&, n&
With Sheets("Devis Clients")
tablo = .Range("A1", .UsedRange).Resize(, 8) 'matrice, plus rapide
End With
ReDim resu(1 To UBound(tablo), 1 To 6)
For i = 25 To UBound(tablo)
If tablo(i, 1) <> "" Then
n = n + 1
resu(n, 2) = tablo(13, 2) 'numéro de compte
resu(n, 1) = tablo(14, 2) 'date mois
resu(n, 3) = tablo(12, 3) 'nom client
resu(n, 5) = tablo(i, 7) 'Qté
resu(n, 6) = tablo(i, 8) 'montant
resu(n, 4) = tablo(i, 1) 'référence
End If
Next
If n = 0 Then Exit Sub
'---restitution---
With Sheets("Suivi Budget geste CO")
If .FilterMode Then .ShowAllData 'si la feuille est filtrée
With .Range("B" & Rows.Count).End(xlUp)(2) '1ère cellule vide en colonne B
.Resize(n, 6) = resu
.Resize(n, 6).Borders.Weight = xlThin 'bordures
.Cells(1, 6).Font.Bold = False
.Cells(n + 1, 6) = "=SUM(R8C:R[-1]C)"
.Cells(n + 1, 6).Font.Bold = True
End With
.Activate 'facultatif
End With
End Sub