Supprimer les "0" de ma liste listbox et combobox

  • Initiateur de la discussion Initiateur de la discussion dgeo27
  • Date de début Date de début

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

dgeo27

XLDnaute Junior
Bonjour, j'ai une liste d'une part avec une listebox (avec prédiction comme google) et d'une autre part une combobox (validation de donnée par liste).
Dans cette liste j'ai des "0" (zéro) qui me sert à rajouter un nouvel article (au lieu de "0" je marque le nom du produit)
Serais il possible de modifier le code vba pour ne pas que mes listes affiche les "0" ?

A) Listbox :
'liste déroulante avec stock'
Private Sub TextBox1_Change()
ListBox1.Clear
For Each cellule In Range("B43:B217")
If InStr(LCase(cellule), LCase(TextBox1.Value)) > 0 Then
ListBox1.AddItem
ListBox1.List(ListBox1.ListCount - 1, 0) = cellule.Value
ListBox1.List(ListBox1.ListCount - 1, 1) = Cells(cellule.Row, 7) 'stock'
ListBox1.List(ListBox1.ListCount - 1, 2) = Cells(cellule.Row, 4) 'ac client'
ListBox1.List(ListBox1.ListCount - 1, 3) = Cells(cellule.Row, 5) 'ac stock'
ListBox1.List(ListBox1.ListCount - 1, 4) = Cells(cellule.Row, 6) 'vendu'
End If
Next cellule
End Sub


B) combobox menu déroulant :
'liste déroulante choix de l'articles'
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect([B4:B39, I4:I39, M4:M39], Target) Is Nothing And Target.Count = 1 Then
a = Application.Transpose(Sheets("Stock").Range("liste"))
Me.ComboBox1.List = a
Me.ComboBox1.Height = Target.Height + 3
Me.ComboBox1.Width = Target.Width
Me.ComboBox1.Top = Target.Top
Me.ComboBox1.Left = Target.Left
Me.ComboBox1 = Target
Me.ComboBox1.Visible = True
Me.ComboBox1.Activate
'Me.ComboBox1.DropDown ' ouverture automatique au clic dans la cellule (optionel)
Else
Me.ComboBox1.Visible = False
End If
End Sub
Private Sub ComboBox1_Change()
If Me.ComboBox1 <> "" And IsError(Application.Match(Me.ComboBox1, a, 0)) Then
Me.ComboBox1.List = Filter(a, Me.ComboBox1.Text, True, vbTextCompare)
Me.ComboBox1.DropDown
End If
ActiveCell.Value = Me.ComboBox1
End Sub
Private Sub ComboBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Me.ComboBox1.List = a
Me.ComboBox1.Activate
Me.ComboBox1.DropDown
End Sub
Private Sub ComboBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 13 Then ActiveCell.Offset(1).Select
End Sub



Merci 🙂
Je suis nul en vba donc si quelqu'un saurais me dire quoi faire 😛
 
Re : Supprimer les "0" de ma liste listbox et combobox

Pour la listbox parfait c'est résolu.
Pour la combo ou mettre le morceau de code ?
j'ai testé sa bug... mais sans savoir ou le mettre

'liste déroulante choix de l'articles'
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect([B4:B39, I4:I39, M4:M39], Target) Is Nothing And Target.Count = 1 Then
a = Application.Transpose(Sheets("Stock").Range("liste "))
Me.ComboBox1.List = a
Me.ComboBox1.Height = Target.Height + 3
Me.ComboBox1.Width = Target.Width
Me.ComboBox1.Top = Target.Top
Me.ComboBox1.Left = Target.Left
Me.ComboBox1 = Target
Me.ComboBox1.Visible = True
Me.ComboBox1.Activate
'Me.ComboBox1.DropDown ' ouverture automatique au clic dans la cellule (optionel)
Else
Me.ComboBox1.Visible = False
End If
End Sub
Private Sub ComboBox1_Change()
If Me.ComboBox1 <> "" And IsError(Application.Match(Me.ComboBox1, a, 0)) Then
Me.ComboBox1.List = Filter(a, Me.ComboBox1.Text, True, vbTextCompare)
Me.ComboBox1.DropDown
End If
ActiveCell.Value = Me.ComboBox1
End Sub
Private Sub ComboBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Me.ComboBox1.List = a
Me.ComboBox1.Activate
Me.ComboBox1.DropDown
End Sub
Private Sub ComboBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 13 Then ActiveCell.Offset(1).Select
End Sub
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD

Discussions similaires

Réponses
3
Affichages
464
Réponses
10
Affichages
759
Réponses
3
Affichages
599
Réponses
4
Affichages
459
  • Question Question
Microsoft 365 worksheet_change
Réponses
29
Affichages
250
Retour