Inverser sens ListBox
Bonsoir,
Est ce possible d'inverser le sens d'une Listbox ?
La listbox me renvoie des données d'une feuille de la ligne3 à ... sans fin
Du coup les dernières lignes enregistrées sont tout en dessous :/
J'aurais bien aimer avoir l'inverse.
Merci à vous
Bonjour,
Si tu la remplis à l'aide d'une boucle, inverse le sens de la boucle
Cordialement
Heu c'est à dire ?
Voici mon code :
'LISTBOX : Facture
Private Sub TextBox94_Change()
ListBox2.Clear
With Sheets("Facturier")
derLigne = .Cells(Rows.Count, 2).End(xlUp).Row
For Each cellule In .Range("A3:A" & derLigne)
If cellule <> 0 Then
If InStr(LCase(cellule), LCase(TextBox94.Value)) > 0 Then
ListBox2.AddItem
ListBox2.List(ListBox2.ListCount - 1, 0) = cellule.Value
ListBox2.List(ListBox2.ListCount - 1, 1) = .Cells(cellule.Row, 2)
ListBox2.List(ListBox2.ListCount - 1, 2) = .Cells(cellule.Row, 4)
ListBox2.List(ListBox2.ListCount - 1, 3) = .Cells(cellule.Row, 5)
ListBox2.List(ListBox2.ListCount - 1, 4) = .Cells(cellule.Row, 6)
ListBox2.List(ListBox2.ListCount - 1, 5) = .Cells(cellule.Row, 7)
ListBox2.List(ListBox2.ListCount - 1, 6) = .Cells(cellule.Row, 8)
ListBox2.List(ListBox2.ListCount - 1, 7) = .Cells(cellule.Row, 9)
End If
End If
Next cellule
End With
End Sub
Peux-tu joindre ton fichier après l'avoir anonymé ?
@+
Bonsoir,
un essai :
'LISTBOX : Facture
Private Sub TextBox94_Change()
Dim DerLigne&, Ligne&
ListBox2.Clear
With Worksheets("Facturier")
derLigne = .Cells(Rows.Count, 2).End(xlUp).Row
For Ligne = derLigne To 3 Step -1
With .Cells(Ligne, 1)
If .Value <> 0 Then
If InStr(LCase$(.Value), LCase$(TextBox94)) > 0 Then
ListBox2.AddItem
ListBox2.List(ListBox2.ListCount - 1, 0) = .Value
ListBox2.List(ListBox2.ListCount - 1, 1) = .Offset(, 1)
ListBox2.List(ListBox2.ListCount - 1, 2) = .Offset(, 3)
ListBox2.List(ListBox2.ListCount - 1, 3) = .Offset(, 4)
ListBox2.List(ListBox2.ListCount - 1, 4) = .Offset(, 5)
ListBox2.List(ListBox2.ListCount - 1, 5) = .Offset(, 6)
ListBox2.List(ListBox2.ListCount - 1, 6) = .Offset(, 7)
ListBox2.List(ListBox2.ListCount - 1, 7) = .Offset(, 8)
End If
End If
End With
Next Ligne
End With
End Sub
dhany
dhany :
1er essai fonctionnel
et beh heu Merci
J'ai l'air d'un c.. mais j'arrive pas à comprend donc à recopier ton code pour mon autre Listbox :/
Listbox devis :
'LISTBOX : Devis
Private Sub TextBox95_Change()
ListBox3.Clear
With Sheets("Devis")
derLigne = .Cells(Rows.Count, 2).End(xlUp).Row
For Each cellule In .Range("A3:A" & derLigne)
If cellule <> 0 Then
If InStr(LCase(cellule), LCase(TextBox95.Value)) > 0 Then
ListBox3.AddItem
ListBox3.List(ListBox3.ListCount - 1, 0) = cellule.Value
ListBox3.List(ListBox3.ListCount - 1, 1) = .Cells(cellule.Row, 2)
ListBox3.List(ListBox3.ListCount - 1, 2) = .Cells(cellule.Row, 4)
ListBox3.List(ListBox3.ListCount - 1, 3) = .Cells(cellule.Row, 5)
ListBox3.List(ListBox3.ListCount - 1, 4) = .Cells(cellule.Row, 6)
ListBox3.List(ListBox3.ListCount - 1, 5) = .Cells(cellule.Row, 7)
ListBox3.List(ListBox3.ListCount - 1, 6) = .Cells(cellule.Row, 8)
ListBox3.List(ListBox3.ListCount - 1, 7) = .Cells(cellule.Row, 9)
End If
End If
Next cellule
End With
End Sub
et la 3ème
listbox client :
'LISTBOX : liste déroulante avec coordonnées clients'
Private Sub TextBox15_Change()
ListBox1.Clear
With Sheets("Listings_clients")
derLigne = .Cells(Rows.Count, 2).End(xlUp).Row
For Each cellule In .Range("B4:B" & derLigne)
If cellule <> 0 Then
If InStr(LCase(cellule), LCase(TextBox15.Value)) > 0 Then
ListBox1.AddItem
ListBox1.List(ListBox1.ListCount - 1, 0) = cellule.Value
ListBox1.List(ListBox1.ListCount - 1, 1) = .Cells(cellule.Row, 3)
ListBox1.List(ListBox1.ListCount - 1, 2) = .Cells(cellule.Row, 4)
ListBox1.List(ListBox1.ListCount - 1, 3) = .Cells(cellule.Row, 5)
ListBox1.List(ListBox1.ListCount - 1, 4) = .Cells(cellule.Row, 6)
ListBox1.List(ListBox1.ListCount - 1, 5) = .Cells(cellule.Row, 7)
ListBox1.List(ListBox1.ListCount - 1, 6) = .Cells(cellule.Row, 8)
ListBox1.List(ListBox1.ListCount - 1, 7) = .Cells(cellule.Row, 9)
ListBox1.List(ListBox1.ListCount - 1, 8) = .Cells(cellule.Row, 10)
ListBox1.List(ListBox1.ListCount - 1, 9) = .Cells(cellule.Row, 11)
End If
End If
Next cellule
End With
End Sub
je peut abuser et te demander de le faire svp ? Merci mille fois
pour la 2ème ListBox :
'LISTBOX : Devis
Private Sub TextBox95_Change()
Dim DerLigne&, Ligne&
ListBox3.Clear
With Worksheets("Devis")
DerLigne = .Cells(Rows.Count, 2).End(xlUp).Row
For Ligne = DerLigne To 3 Step -1
With .Cells(Ligne, 1)
If .Value <> 0 Then
If InStr(LCase$(.Value), LCase$(TextBox95)) > 0 Then
ListBox3.AddItem
ListBox3.List(ListBox3.ListCount - 1, 0) = .Value
ListBox3.List(ListBox3.ListCount - 1, 1) = .Offset(, 1)
ListBox3.List(ListBox3.ListCount - 1, 2) = .Offset(, 3)
ListBox3.List(ListBox3.ListCount - 1, 3) = .Offset(, 4)
ListBox3.List(ListBox3.ListCount - 1, 4) = .Offset(, 5)
ListBox3.List(ListBox3.ListCount - 1, 5) = .Offset(, 6)
ListBox3.List(ListBox3.ListCount - 1, 6) = .Offset(, 7)
ListBox3.List(ListBox3.ListCount - 1, 7) = .Offset(, 8)
End If
End If
End With
Next Ligne
End With
End Sub
Merci dhany, j'ai eu une absence pour un autre dossier.
Bonne soirée
de rien !
dhany
pour la 3ème ListBox :
'LISTBOX : liste déroulante avec coordonnées clients
Private Sub TextBox15_Change()
Dim DerLigne&, Ligne&
ListBox1.Clear
With Worksheets("Listings_clients")
DerLigne = .Cells(Rows.Count, 2).End(xlUp).Row
For Ligne = DerLigne To 4 Step -1
With .Cells(Ligne, 2)
If .Value <> 0 Then
If InStr(LCase$(.Value), LCase$(TextBox15)) > 0 Then
ListBox1.AddItem
ListBox1.List(ListBox1.ListCount - 1, 0) = .Value
ListBox1.List(ListBox1.ListCount - 1, 1) = .Offset(, 2)
ListBox1.List(ListBox1.ListCount - 1, 2) = .Offset(, 3)
ListBox1.List(ListBox1.ListCount - 1, 3) = .Offset(, 4)
ListBox1.List(ListBox1.ListCount - 1, 4) = .Offset(, 5)
ListBox1.List(ListBox1.ListCount - 1, 5) = .Offset(, 6)
ListBox1.List(ListBox1.ListCount - 1, 6) = .Offset(, 7)
ListBox1.List(ListBox1.ListCount - 1, 7) = .Offset(, 8)
ListBox1.List(ListBox1.ListCount - 1, 8) = .Offset(, 9)
ListBox1.List(ListBox1.ListCount - 1, 9) = .Offset(, 10)
End If
End If
End With
Next Ligne
End With
End Sub
on dirait qu'ça s'rait kek'chose dans c'genre-là :
'LISTBOX : liste déroulante avec coordonnées clients
Private Sub TextBox15_Change()
Dim DerLigne&, Ligne&
ListBox1.Clear
With Worksheets("Listings_clients")
DerLigne = .Cells(Rows.Count, 2).End(xlUp).Row
For Ligne = DerLigne To 4 Step -1
With .Cells(Ligne, 2)
If .Value <> 0 Then
If InStr(LCase$(.Value), LCase$(TextBox15)) > 0 Then
ListBox1.AddItem ' colonne
' ListBox1.List(ListBox1.ListCount - 1, 0) = ? 'Nom ?
' ListBox1.List(ListBox1.ListCount - 1, 1) = ? 'Prénom ?
ListBox1.List(ListBox1.ListCount - 1, 2) = .Value 'Société B
ListBox1.List(ListBox1.ListCount - 1, 3) = .Offset(, 2) 'Adresse D
ListBox1.List(ListBox1.ListCount - 1, 4) = .Offset(, 3) 'C.P E
ListBox1.List(ListBox1.ListCount - 1, 5) = .Offset(, 4) 'Ville F
ListBox1.List(ListBox1.ListCount - 1, 6) = .Offset(, 5) 'Tél G
ListBox1.List(ListBox1.ListCount - 1, 7) = .Offset(, 6) 'Mail H
ListBox1.List(ListBox1.ListCount - 1, 8) = .Offset(, 7) 'Num T.V.A I
End If
End If
End With
Next Ligne
End With
End Sub
mais sans ton fichier, c'est pas évident ! faudrait voir sur ta feuille "Listings_clients" la colonne de chaque donnée !
dhany
Après une nuit de sommeil c'est mieux
Private Sub TextBox15_Change()
Dim DerLigne&, Ligne&
ListBox1.Clear
With Worksheets("Listings_clients")
DerLigne = .Cells(Rows.Count, 2).End(xlUp).Row
For Ligne = DerLigne To 4 Step -1
With .Cells(Ligne, 2)
If .Value <> 0 Then
If InStr(LCase$(.Value), LCase$(TextBox15)) > 0 Then
ListBox1.AddItem 'colonne
ListBox1.List(ListBox1.ListCount - 1, 0) = .Value 'Nom
ListBox1.List(ListBox1.ListCount - 1, 1) = .Offset(, 1) 'Prénom
ListBox1.List(ListBox1.ListCount - 1, 2) = .Offset(, 2) 'Société
ListBox1.List(ListBox1.ListCount - 1, 3) = .Offset(, 3) 'Adresse D
ListBox1.List(ListBox1.ListCount - 1, 4) = .Offset(, 4) 'C.P E
ListBox1.List(ListBox1.ListCount - 1, 5) = .Offset(, 5) 'Ville F
ListBox1.List(ListBox1.ListCount - 1, 6) = .Offset(, 6) 'Tél G
ListBox1.List(ListBox1.ListCount - 1, 7) = .Offset(, 7) 'Mail H
ListBox1.List(ListBox1.ListCount - 1, 8) = .Offset(, 8) 'Num T.V.A I
End If
End If
End With
Next Ligne
End With
End Sub
Merci à toi
Je ne sais pas du tout si on peut le faire mais est ce possible de surligner ou d'afficher des lignes (qui s'affiche dans la Listbox Facture) selon condition ? En gros si la facture d'acompte n'as pas de facture final alors il s'affiche en rouge ...
Juste pour faire ressortir les Facture en cours en gros ... ?
petite rectification de ton code VBA (uniquement commentaires en vert, indication des colonnes)
Private Sub TextBox15_Change()
Dim DerLigne&, Ligne&
ListBox1.Clear
With Worksheets("Listings_clients")
DerLigne = .Cells(Rows.Count, 2).End(xlUp).Row
For Ligne = DerLigne To 4 Step -1
With .Cells(Ligne, 2)
If .Value <> 0 Then
If InStr(LCase$(.Value), LCase$(TextBox15)) > 0 Then
ListBox1.AddItem ' colonne
ListBox1.List(ListBox1.ListCount - 1, 0) = .Value 'Nom B
ListBox1.List(ListBox1.ListCount - 1, 1) = .Offset(, 1) 'Prénom C
ListBox1.List(ListBox1.ListCount - 1, 2) = .Offset(, 2) 'Société D
ListBox1.List(ListBox1.ListCount - 1, 3) = .Offset(, 3) 'Adresse E
ListBox1.List(ListBox1.ListCount - 1, 4) = .Offset(, 4) 'C.P F
ListBox1.List(ListBox1.ListCount - 1, 5) = .Offset(, 5) 'Ville G
ListBox1.List(ListBox1.ListCount - 1, 6) = .Offset(, 6) 'Tél H
ListBox1.List(ListBox1.ListCount - 1, 7) = .Offset(, 7) 'Mail I
ListBox1.List(ListBox1.ListCount - 1, 8) = .Offset(, 8) 'Num T.V.A J
End If
End If
End With
Next Ligne
End With
End Sub
car With .Cells(Ligne, 2) ➯ .Value = colonne B ; et .Offset 1 à 8 = colonne C à J
dhany
pour la nouvelle demande de ton post de 9:01, je n'ai pas de solution à proposer ; mais comme c'est très différent de ce sujet, tu devrais en créer un autre ; bonne chance !
dhany
Parfait je vais voir, merci mille fois
Bonjour à tous,
J'ai un problème à la fois similaire et différent.
Je ne sais point inverser le sens du contenu de ma listbox vu que j'ai spécifié une sélection > Range("D4:D9") et pas une à une.
La flèche d'en haut supposée incrémenter ma valeur (passer à la valeur suivante de la colonne D) fait l'inverse et inversement pour celle d'en bas.
Voici mon code :
' Liste Nb Sources
Dim NbSources As Range
For Each NbSources In ws.Range("D4:D9")
With Me.ListBox18
.AddItem NbSources.Value & " min"
End With
Next NbSources
For Each NbSources In ws.Range("D4:D9")
With Me.ListBox19
.AddItem NbSources.Value & " max"
End With
Next NbSources
Merci de m'aider sur ce point.
Bonne journée.