Supprimer ligne
BONJOUR
je souhaite, pour une ligne sélectionnée dans la listbox2, pouvoir la supprimer de la base de donnée
merci
Private Sub DeleteRow_Click()
''Delete Range("A:E" )
Dim i As Integer
If MsgBox("are you sure want to delete this rows?", vbYesNo + vbQuestion, "delete row") = vbYes Then
For i = 2 To Feuil1.Range("A10000").End(xlUp).Row
If Cells(i, 1) = ListBox1.List(ListBox1.ListIndex) Then
'Rows(i).Select
Feuil1.Range("A" & i, "E" & i).Select
Selection.Delete
End If
Next i
End If
ListBox2.Clear
Me.ListBox2.AddItem
For x = 2 To 5
Me.ListBox2.List(0, x - 2) = Feuil1.Cells(1, x)
Next x
Me.ListBox2.Selected(0) = True
For i = 2 To Application.WorksheetFunction.CountA(Feuil1.Range("A:A")) '**********
If Feuil1.Cells(i, 1) = Me.ListBox1.Column(0) Then
Me.ListBox2.AddItem
For r = 2 To 5
Me.ListBox2.List(ListBox2.ListCount - 1, r - 2) = Feuil1.Cells(i, r)
Next r
End If
Next i
End Sub
Bonjour,
à tester,
If Cells(i, 1) = ListBox1.List(ListBox1.ListIndex) And Cells(i, 3) = CInt(ListBox2.List(ListBox2.ListIndex, 1)) Then
BONJOUR
Résolut
RESTE
Comment Actualiser listbox1 pour que le Montant du listbox1= Somme du Montant Listbox2
MERCI
BONJOUR
Je pense que la solution comme ça
Private Sub DeleteRow_Click()
''Delete Range("A:E" )
Dim i As Integer
If MsgBox("are you sure want to delete this rows?", vbYesNo + vbQuestion, "delete row") = vbYes Then
For i = 2 To Feuil1.Range("A10000").End(xlUp).Row
'If Cells(i, 1) = ListBox1.List(ListBox1.ListIndex) Then
If Cells(i, 1) = ListBox1.List(ListBox1.ListIndex) And Cells(i, 3) = CInt(ListBox2.List(ListBox2.ListIndex, 1)) Then
'Rows(i).Select
Feuil1.Range("A" & i, "E" & i).Select
Selection.Delete
End If
Next i
End If
ListBox2.Clear
Me.ListBox2.AddItem
For x = 2 To 5
Me.ListBox2.List(0, x - 2) = Feuil1.Cells(1, x)
Next x
Me.ListBox2.Selected(0) = True
For i = 2 To Application.WorksheetFunction.CountA(Feuil1.Range("A:A")) '**********
If Feuil1.Cells(i, 1) = Me.ListBox1.Column(0) Then
Me.ListBox2.AddItem
For r = 2 To 5
Me.ListBox2.List(ListBox2.ListCount - 1, r - 2) = Feuil1.Cells(i, r)
Next r
End If
Next i
'for listbox sum
For r = 1 To Me.ListBox1.ListCount - 1 '************** 1
B = Application.WorksheetFunction.SUMIF(Feuil1.Range("A:A"), Me.ListBox1.List(r, 0), Feuil1.Range("B:B"))
Me.ListBox1.List(r, 1) = B & ".00"
Next r
End Sub
Merci