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 28 29 30 31 32 33 34 35 36 37 38
| Sub fournisseurs()
nb_ligne = 2
While Cells(nb_ligne, 1) <> ""
nb_ligne = nb_ligne + 1
Wend
nb_ligne = nb_ligne - 1
'Filtrer les fournisseurs
Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select
Range("A1:B5").Sort Key1:=Range("A2"), Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
'met dans feuille
i = 0
For i = 2 To nb_ligne
Worksheets("Feuil1").Activate
If Cells(i, 1) = Cells(i + 1, 1) Then
somme = Cells(i, 2)
While Cells(i, 1) = Cells(i + 1, 1) And Cells(i, 1) <> ""
somme = somme + Cells(i + 1, 2)
i = i + 1
Wend
Worksheets.Add.Name = Cells(i - 1, 1)
Cells(1, 1) = somme
Else
somme = Cells(i, 2)
Worksheets.Add.Name = Cells(i, 1)
Cells(1, 1) = somme
End If
Next i
End Sub |
Partager