Ceci est une page optimisée pour les mobiles. Cliquez sur ce texte pour afficher la vraie page.

Supprimer les "0" de ma liste listbox et combobox

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
 

Lone-wolf

XLDnaute Barbatruc
Re : Supprimer les "0" de ma liste listbox et combobox

Bonjour djeo,

Un essai comme ceci.

Me.ComboBox1.List = Replace(a, "0", "")

ListBox1.List(ListBox1.ListCount - 1, 1) = Replace(Cells(cellule.Row, 7), "0", "")


A+
 

dgeo27

XLDnaute Junior
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
 

Discussions similaires

Réponses
4
Affichages
217
Réponses
17
Affichages
849
Les cookies sont requis pour utiliser ce site. Vous devez les accepter pour continuer à utiliser le site. En savoir plus…