XL 2019 Afficher lignes dans LISTBOX

  • Initiateur de la discussion Initiateur de la discussion guiyom
  • 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 !

guiyom

XLDnaute Junior
Bonsoir,

J'aurais besoin de vos lumières sur la possibilité ou non de pouvoir afficher uniquement les valeurs de la colonne TOTAL différent de 0 dans la LISTBOX.

La source de la LISTBOX est appelée via :

VB:
Private Sub UserForm_Initialize()

ListBox1.List = Sheets("Feuil1").Range("D11:L36").Value

End Sub

Je joint un fichier d'exemple

Cordialement
 

Pièces jointes

Bonsoir @guiyom , le Forum

Tu devrais faire un essai comme ceci dans ton UserForm6 :

VB:
Option Explicit

Private Sub UserForm_Initialize()
Dim Ws As Worksheet
Dim RngPlage As Range
Dim TabPlage As Variant
Dim i As Integer, x As Integer
Dim c As Byte

Set Ws = ThisWorkbook.Worksheets("Feuil1")
Set RngPlage = Ws.Range("D11:L" & Ws.Range("L1000").End(xlUp).Row)
TabPlage = RngPlage

'ListBox1.List = TabPlage '>>>> SANS FILTRE

For i = 1 To UBound(TabPlage, 1)
    If TabPlage(i, 9) <> 0 Then ' >>>>>>>>>> LE FILTRE !!!
        With Me.ListBox1
        .TextAlign = fmTextAlignRight
            .AddItem TabPlage(i, 1)
                For c = 1 To 8
'                    .Column(c, x) = TabPlage(i, c + 1) ">>>> Without Format
                    .Column(c, x) = Format(TabPlage(i, c + 1), "# ### ### ##0.00")
                Next c
         x = x + 1
         End With
    End If
Next i

End Sub

Bonne soirée
@+Thierry
 
Bonsoir @guiyom , le Forum

Tu devrais faire un essai comme ceci dans ton UserForm6 :

VB:
Option Explicit

Private Sub UserForm_Initialize()
Dim Ws As Worksheet
Dim RngPlage As Range
Dim TabPlage As Variant
Dim i As Integer, x As Integer
Dim c As Byte

Set Ws = ThisWorkbook.Worksheets("Feuil1")
Set RngPlage = Ws.Range("D11:L" & Ws.Range("L1000").End(xlUp).Row)
TabPlage = RngPlage

'ListBox1.List = TabPlage '>>>> SANS FILTRE

For i = 1 To UBound(TabPlage, 1)
    If TabPlage(i, 9) <> 0 Then ' >>>>>>>>>> LE FILTRE !!!
        With Me.ListBox1
        .TextAlign = fmTextAlignRight
            .AddItem TabPlage(i, 1)
                For c = 1 To 8
'                    .Column(c, x) = TabPlage(i, c + 1) ">>>> Without Format
                    .Column(c, x) = Format(TabPlage(i, c + 1), "# ### ### ##0.00")
                Next c
         x = x + 1
         End With
    End If
Next i

End Sub

Bonne soirée
@+Thierry
Bonjour @thierry, le forum

C'est exactement le résultat recherché, merci pour le temps que vous avez accordé à mon probléme.

Pas mal de termes que je ne connais pas, je vais regarder ça.

Merci et bonne journée.
 
Bonjour @guiyom 🙂, @_Thierry 😉,

Pour le fun et vous saluer 🙂 :
VB:
Private Sub UserForm_Initialize()
Dim t, n&, i&, j&, p&
   With Sheets("Feuil1")
      If .FilterMode Then .ShowAllData
      t = .Range("d11:L" & .Cells(.Rows.Count, "d").End(xlUp).Row)
      For i = 1 To UBound(t): n = n - (t(i, UBound(t, 2)) <> 0): Next
      If n > 0 Then ReDim r(1 To n, 1 To 9) Else Exit Sub
      For i = 1 To UBound(t)
         If t(i, UBound(t, 2)) <> 0 Then p = p + 1: For j = 1 To UBound(t, 2): r(p, j) = t(i, j): Next
      Next i
      ListBox1.List = r: ListBox1.TextAlign = fmTextAlignRight
   End With
End Sub
 

Pièces jointes

Re,

Une autre version toujours pour le fun :
VB:
Private Sub UserForm_Initialize()
Dim i&
   With Sheets("Feuil1")
      If .FilterMode Then .ShowAllData
      ListBox1.List = .Range("d11:L" & .Cells(.Rows.Count, "d").End(xlUp).Row).Value
      For i = ListBox1.ListCount - 1 To 0 Step -1
         If ListBox1.List(i, 8) = 0 Then ListBox1.RemoveItem i
      Next i
      ListBox1.TextAlign = fmTextAlignRight
   End With
End Sub
 

Pièces jointes

- 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
10
Affichages
531
Réponses
12
Affichages
591
Réponses
7
Affichages
494
Réponses
5
Affichages
312
Retour