bonjour cher developpeurs
j(ai un probleme avec un application basée sur excel avec une interface VBA
le code suivant c'est pour modifier un facture
la partie en gras/ rouge est la partie concerné
merci d'avence
---------------------------------
Private Sub cmdupdate_Click()
Feuil6.Range("M2").Value = Me.Textabider.Value
Dim new_abider As Long
new_abider = Val(Feuil6.Range("M2").Value) - Val(Feuil6.Range("L2").Value)
Feuil5.Range("F1").Value = Me.Textclient.Value
Dim client_lr As Integer
Dim lsum As Long
Dim vdiscond As Long
client_lr = Feuil5.Range("G1").Value
lsum = Application.WorksheetFunction.Sum(Feuil6.Range("I2:I1000"))
vdiscond = Val(lsum) * Val(Me.Textdiscond.Value) / 100
''Feuil5.Cells(client_lr, "C").Value = Val(lsum) - Val(vdiscond)
Feuil5.Cells(client_lr, "C").Value = Val(Feuil5.Cells(client_lr, "C").Value) + Val(lsum) - Val(vdiscond)
Feuil5.Cells(client_lr, "E").Value = Val(Feuil5.Cells(client_lr, "E").Value) + Val(new_abider)
'' modification du stock après la modification de facture
Dim lfor1, pr_help3, pr_stor1 As Integer
pr_help3 = Feuil6.Range("A100").End(xlUp).Row
For lfor1 = 2 To pr_help3
Feuil3.Range("N2").Value = Feuil6.Cells(lfor1, "A").Value
pr_stor1 = Feuil3.Range("O2").Value
Feuil3.Cells(pr_stor1, "K").Value = Val(Feuil3.Cells(pr_stor1, "k").Value) + Val(Feuil6.Cells(lfor1, "H").Value)
Feuil3.Cells(pr_stor1, "L").Value = Val(Feuil3.Cells(pr_stor1, "L").Value) - Val(Feuil6.Cells(lfor1, "H").Value)
Next lfor1
''modification feuil2 des ventes
Dim fr1, fr2, lr1, lr2 As Integer
lr1 = Feuil2.Range("A10000").End(xlUp).Row
lr2 = Feuil6.Range("A").End(xlUp).Row
For fr1 = 2 To lr1
For fr2 = 2 To lr2
If Feuil2.Cells(fr1, "A").Text = Me.Textnbrfc.Text And _
Feuil2.Cells(fr1, "D").Value = Feuil6.Cells(fr2, "A").Value Then
''Feuil2.Range("A:L").EntireRow.Delete
Feuil2.Cells(fr1).Delete
lr1 = lr1 + 1
lr2 = lr2 + 1
End If
Next
Next
Dim i, updat_invoice, updat_product As Integer
updat_invoice = Feuil2.Range("A10000").End(xlUp).Row + 1
updat_product = Feuil6.Range("A100").End(xlUp).Row
For i = 2 To updat_product
Feuil2.Cells(updat_invoice, "A").Value = Me.Textnbrfc.Value
Feuil2.Cells(updat_invoice, "B").Value = Format(Me.Textdate.Value, "dd/mm/yyyy")
Feuil2.Cells(updat_invoice, "C").Value = Me.Textclient.Value
Feuil2.Cells(updat_invoice, "H").Value = Me.Textsubtotal.Value
Feuil2.Cells(updat_invoice, "I").Value = Me.Textdiscond.Value
Feuil2.Cells(updat_invoice, "J").Value = Me.Texttotal.Value
Feuil2.Cells(updat_invoice, "k").Value = Me.Textpaid.Value
Feuil2.Cells(updat_invoice, "L").Value = Me.Textabider.Value
'''information variable
Feuil2.Cells(updat_invoice, "D").Value = Feuil6.Cells(i, "A").Value
Feuil2.Cells(updat_invoice, "F").Value = Feuil6.Cells(i, "B").Value
Feuil2.Cells(updat_invoice, "G").Value = Feuil6.Cells(i, "C").Value
updat_invoice = updat_invoice + 1
Next i
'Dim total_data As Range
'Dim colm_stor As Range
'Set total_data = Worksheets("vente").Range("A:L")
'Set colm_stor = Worksheets("vente").Range("A:A")
'total_data.Sort key1:=colm_stor, order1:=xlAscending, Header:=xlYes
ThisWorkbook.Save
MsgBox "modifier avec succé ", vbInformation + vbMsgBoxRight + vbMsgBoxRtlReading, "confirmation"
End Sub
Partager