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
| Private Sub Factur_Caisses_Click()
Dim ligExport As Long, lNumFacture As Long, oCellNumFacture As Range
Dim booAddFacture As Boolean
'Dim ligExport As Long
ligExport = Feuil2.Range("a" & Rows.Count).End(xlUp).Row + 1
'Affectation de la cellule contanant le numéro de facture à incrémenter
Set oCellNumFacture = ThisWorkbook.Names("NumFacture").RefersToRange
'If Me.Combo_Serveur <> "" And Me.TextBox_Réf <> "" Then 'si service et ref renseignés
For i = 1 To 10 'pour toutes les lignes
If Me.Controls("ComboBox_Bois" & i) <> "" And Me.Controls("TextBox_Qte" & i) <> "" Then 'si tous les contrôles de la ligne sont remplis
If Not booAddFacture Then
booAddFacture = True
lNumFacture = oCellNumFacture.Value + 1
oCellNumFacture.Value = lNumFacture
Me.TextBox_Réf.Value = "FA" & Format(lNumFacture, "00000")
End If
'export
With Feuil2
.Range("a" & ligExport) = Date
.Range("b" & ligExport) = Me.Controls("ComboBox_Bois" & i)
.Range("c" & ligExport) = CDbl(Me.Controls("TextBox_Qte" & i))
.Range("d" & ligExport) = CDbl(Me.Controls("TextBox_Mtant" & i))
.Range("e" & ligExport) = Me.Combo_Serveur
.Range("f" & ligExport) = Me.TextBox_Réf
.Range("g" & ligExport) = Me.CodeExpl
.Range("h" & ligExport) = CDbl(Me.TextBox_Encais)
.Range("i" & ligExport) = CDbl(Me.TextBox_Avoir)
.Range("j" & ligExport) = CDbl(Me.TextBox_Reste)
End With
'incrémentation de la ligne
ligExport = ligExport + 1
End If
Next i
'End If
End Sub |
Partager