XL 2013 ListBox.AddItem

pompaero

XLDnaute Impliqué
Bonjour à tous

J'ai un petit soucis avec l'AddItem d'une listbox. Je cherche à créer sur un bouton Modifier le code :
Si feuill 1 colonne F est égale à AddItem de listbox1 alors je modifier.
J'ai fais ce début de code If tabArticles(i, 6) = Me.Lst_Panier.AddItem Then mais ca bug.
Code:
Private Sub CommandButton10_Click()
Dim i As Long, j As Long
Dim tabArticles() As Variant
Dim nbLignes As Long

nbLignes = ThisWorkbook.Sheets("Panier").Range("A65536").End(xlUp).Row
tabArticles = ThisWorkbook.Sheets("Panier").Range("A1:R" & nbLignes + 1).Value
For i = 1 To nbLignes
If tabArticles(i, 6) = Me.Lst_Panier.AddItem Then
    If MsgBox("Voulez vous MODIFIER l'enregistrement de l'article ?", _
    vbQuestion + vbYesNo, "Modification") <> vbYes Then Exit Sub
    tabArticles(i, 5) = Me.TextBox1.Value
    tabArticles(i, 12) = Me.TextBox2.Value
    Exit For
End If
Next i
ThisWorkbook.Sheets("Panier").Range("A1:R" & nbLignes + 1).Value = tabArticles
End Sub

Je dois passer certainement à côté de quelque chose de simple
Merci de votre aide.

Cdlt
 

Paritec

XLDnaute Barbatruc
Bonjour Pompaero le forum
voilà tu changes tout le ci-dessous dans ton code d'userform, et tu auras tes totaux à jour et aussi le bouton supprimer et modifier.
a+
Papou:)

en haut
Dim WsPanier As Worksheet, nb&

Private Sub CommandButton10_Click()
Dim i As Long, j As Long
Dim tabArticles() As Variant
Dim nbLignes As Long
nbLignes = ThisWorkbook.Sheets("Panier").Range("A65536").End(xlUp).Row
tabArticles = ThisWorkbook.Sheets("Panier").Range("A1:R" & nbLignes + 1).Value
For i = 1 To nbLignes
If tabArticles(i, 6) = Me.Lst_Panier Then
If MsgBox("Voulez vous MODIFIER l'enregistrement de l'article ?", _
vbQuestion + vbYesNo, "Modification") <> vbYes Then Exit Sub
tabArticles(i, 5) = Me.TextBox1.Value
tabArticles(i, 12) = Me.TextBox2.Value
tabArticles(i, 16) = Me.TextBox1.Value * tabArticles(i, 13)
Me.Lst_Panier.List(Me.Lst_Panier.ListIndex, 1) = Me.TextBox1.Value
Me.Lst_Panier.List(Me.Lst_Panier.ListIndex, 3) = Me.TextBox2.Value
Me.Lst_Panier.List(Me.Lst_Panier.ListIndex, 5) = tabArticles(i, 16)
Exit For
End If
Next i
Call TotalSommePanier
ThisWorkbook.Sheets("Panier").Range("A1:R" & nbLignes + 1).Value = tabArticles
End Sub

Private Sub CommandButton11_Click()
Dim cel As Range, rep, lig&
If Lst_Panier.ListIndex = -1 Then Exit Sub
rep = MsgBox("Vous allez Supprimer le ligne sélectionnée,, Voulez Vous Vraiment Continuer? ATTENTION Action Irréversible!!!", vbCritical + vbYesNo, "Suppression de ligne")
If rep = vbNo Then Exit Sub
lig = Lst_Panier.ListIndex + 2
Feuil6.Rows(lig).Delete shift:=xlUp
Lst_Panier.RemoveItem (Lst_Panier.ListIndex)
Lst_Panier.ListIndex = -1
Call TotalSommePanier
End Sub

Sub TotalSommePanier()
Dim var As Integer
Dim i&
For i = 0 To Me.Lst_Panier.ListCount - 1
var = var + Me.Lst_Panier.Column(5, i)
Next i
Me.TextBox4.Value = var
Me.TextBox4.Value = Format(Me.TextBox4.Value, "###.00")
Call TotalArticlePanier
Label54 = "Panier avec ( " & nb & " ) articles, pour " & Format(var, "###.00") & "€"
End Sub

Sub TotalArticlePanier()
Dim var As Integer
Dim i As Long
For i = 0 To Me.Lst_Panier.ListCount - 1
var = var + Me.Lst_Panier.Column(1, i)
Next i
Me.TextBox5.Value = var
nb = var
End Sub
 
Dernière édition:

Statistiques des forums

Discussions
312 972
Messages
2 094 055
Membres
105 930
dernier inscrit
Manoa