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 39 40 41 42
| Sub diviserFacture()
Dim F1 As Worksheet
Dim F2 As Worksheet
Set F1 = Sheets("Feuil1")
Set F2 = Sheets("Feuil2")
Application.ScreenUpdating = False
F2.Cells.ClearContents
F2.Range("A3") = F1.Range("A3")
F2.Range("A7") = F1.Range("A7")
F2.Range("b7") = F1.Range("b7")
F2.Range("c7") = F1.Range("c7")
F2.Range("d7") = F1.Range("d7")
F2.Range("e7") = F1.Range("e7")
Dim Tablo
Dim i As Long
Tablo = F1.Range("A8", "E" & F1.Range("E" & Rows.Count).End(xlUp).Row)
L = 8
For i = LBound(Tablo, 1) To UBound(Tablo, 1)
If Tablo(i, 1) <> "" Then
nb = Int(Tablo(i, 5) / 5000)
For Fact = 1 To nb
F2.Cells(L, 1) = Tablo(i, 1)
F2.Cells(L, 2) = Tablo(i, 2)
F2.Cells(L, 3) = Tablo(i, 3)
F2.Cells(L, 4) = Tablo(i, 4) & "-" & Fact
F2.Cells(L, 5) = 5000
L = L + 1
Next Fact
F2.Cells(L, 1) = Tablo(i, 1)
F2.Cells(L, 2) = Tablo(i, 2)
F2.Cells(L, 3) = Tablo(i, 3)
F2.Cells(L, 4) = Tablo(i, 4) & "-" & (nb + 1)
F2.Cells(L, 5) = Tablo(i, 5) - (5000 * nb)
L = L + 1
End If
Next i
F2.Select
MsgBox ("Oumourek 6 zit sahbi")
Application.ScreenUpdating = True
End Sub |
Partager