soucis avec un code pour supprimé

petchy

XLDnaute Occasionnel
bonjour à tous
j'ai un soucis avec se code pour supprimé l'article sur la feuille 'base'

auriez vous une idée
Code:
Private Sub CommandButton3_Click()
Dim Msg As String
Dim NomLBindex
Dim WsBase
Msg = MsgBox('Etes-vous sur de vouloir supprimer ' _
& vbCrLf & vbCrLf & vbTab & ListBox1 & ' ?', vbYesNo, 'Mode Supression Articles ???')
If Msg = vbYes Then
ListBox1.Value = ''
With WsBase
[color=#FFFF00].Rows(NomLBindex).Delete[/color]
End With
End If
End Sub
;) :eek:
merci
 

petchy

XLDnaute Occasionnel
Re

j'ai essayé un autre code,je n'ait pas d'erreur mais il ne me supprime pas l'article sélectionné

Code:
Private Sub CommandButton2_Click()
Dim Msg As String
 Msg = MsgBox('Etes-vous sur de vouloir supprimer ' _
& vbCrLf & vbCrLf & vbTab & ListBox1 & ' ?', vbYesNo, 'Mode Supression Articles ???')
If Msg = vbYes Then
    Sheets('base').Select
    Selection.Delete Shift:=xlUp
    REPERT.ListBox1.ListIndex = -1
    ParamFiltre TabStrip1.Value
End If
End Sub
:silly:
 

MichelXld

XLDnaute Barbatruc
rebonsoir Petchy

tu n'as pas bien compris ce que je voulais te dire dans mon premier message ...


tu peux tester macro :
si tu supprimes la ligne 2 dans la listbox cela supprime la 2eme ligne dans la feuille 'base'


Private Sub CommandButton3_Click()
Dim Msg As String
Dim NomLBindex As Integer
Dim WsBase As Worksheet
Msg = MsgBox('Etes-vous sur de vouloir supprimer ' _
& vbCrLf & vbCrLf & vbTab & ListBox1 & ' ?', vbYesNo, 'Mode Supression Articles ???')

NomLBindex = ListBox1.ListIndex + 1
If Msg = vbYes Then
ListBox1.RemoveItem (ListBox1.ListIndex)
Sheets('base').Rows(NomLBindex).Delete
End If
End Sub


bonne soiree
MichelXld
 

petchy

XLDnaute Occasionnel
Merci MichelXLD pour la modif,ça fonctionne super bien,
pour répondre à ta question:
en fait j'ai repris un code d'une autre appli et j'ai un peu de mal avec les variables,j'ai du mal à savoir à quoi ça correspond.
si tu pouvais m'éclairé B) se serait sympa.
encore merci pour ta réponse
 

MichelXld

XLDnaute Barbatruc
rebonsoir Petchy

tu peux tester cette adaptation


Private Sub CommandButton3_Click()
Dim Msg As String
Dim NomLBindex As Integer

If ListBox1.ListIndex = -1 Then
MsgBox 'Aucune ligne sélectionnée '
Exit Sub
End If

Msg = MsgBox('Etes-vous sur de vouloir supprimer ' _
& vbCrLf & vbCrLf & vbTab & ListBox1 & ' ?', vbYesNo, 'Mode Supression Articles ???')

NomLBindex = ListBox1.ListIndex + 1
If Msg = vbYes Then
ListBox1.RemoveItem (ListBox1.ListIndex)
Sheets('base').Rows(NomLBindex).Delete
End If
End Sub



bonne soiree
MichelXld
 

Discussions similaires

Statistiques des forums

Discussions
314 017
Messages
2 104 582
Membres
109 083
dernier inscrit
Stef06