Listbox avec plus de 10 colonnes

dam3117

XLDnaute Occasionnel
Bonjour,
J 'aurai besoin d'une listbox avec 23 colonnes, mais à 10 colonnes ça bug!!!
Quelqu'un aurais t'il une solution?
Merci
Damien
 

dam3117

XLDnaute Occasionnel
Re : Listbox avec plus de 10 colonnes

Re, voici mon code mais cela bug toujours à la 10 ème:

Sub BILANAGREAGE()

Dim reponse As String

'Windows("base peche.xls").Activate
Sheets("BASE").Activate

Dim TheDate As Date ' Déclare les variables.
Dim Msg
Dim c, x As Long

reponse = InputBox("Entrez une date (jj/mm/aaaa)", "Création du bilan agréage du... ")


If IsDate(reponse) Then
TheDate = reponse
UserForm3.Label2 = Date - DateDiff("d", TheDate, Now)
UserForm3.Caption = "Bilan agréage du :" & TheDate
x = 0

For Each n In Worksheets("BASE").Range("a11:a" & Range("A65536").End(xlUp).Row)

If n = UserForm3.Label2 Then
a = n.Row

UserForm3.ListBox1.AddItem Cells(a, 2)
UserForm3.ListBox1.List(x, 1) = Cells(a, 3)
UserForm3.ListBox1.List(x, 2) = Cells(a, 4)
UserForm3.ListBox1.List(x, 3) = Cells(a, 16)
UserForm3.ListBox1.List(x, 4) = Cells(a, 23)
UserForm3.ListBox1.List(x, 5) = Cells(a, 18)
UserForm3.ListBox1.List(x, 6) = Cells(a, 21)
UserForm3.ListBox1.List(x, 7) = Cells(a, 32)
UserForm3.ListBox1.List(x, 8) = Cells(a, 22)
UserForm3.ListBox1.List(x, 9) = Cells(a, 29)
UserForm3.ListBox1.List(x, 10) = Cells(a, 30)
UserForm3.ListBox1.List(x, 11) = Cells(a, 27)
UserForm3.ListBox1.List(x, 12) = Cells(a, 28)
UserForm3.ListBox1.List(x, 13) = Cells(a, 26)
UserForm3.ListBox1.List(x, 14) = Cells(a, 15)
UserForm3.ListBox1.List(x, 15) = Cells(a, 24)
UserForm3.ListBox1.List(x, 16) = Cells(a, 25)
UserForm3.ListBox1.List(x, 17) = Cells(a, 19)
UserForm3.ListBox1.List(x, 18) = Cells(a, 20)
UserForm3.ListBox1.List(x, 19) = Cells(a, 31)
UserForm3.ListBox1.List(x, 20) = Cells(a, 34)
UserForm3.ListBox1.List(x, 21) = Cells(a, 35)
UserForm3.ListBox1.List(x, 22) = Cells(a, 36)
x = x + 1
End If
Next n
If UserForm3.ListBox1.ListCount > 0 Then
UserForm3.Label4.Caption = ""
ElseIf UserForm3.ListBox1.ListCount = 0 Then UserForm3.Label4.Caption = "PAS DE CONTRÔLE CE JOUR"
End If
If UserForm3.Label4.Caption = "PAS DE CONTRÔLE CE JOUR" Then UserForm3.Label4.Visible = True
If UserForm3.Label4.Caption = "PAS DE CONTRÔLE CE JOUR" Then UserForm3.ListBox1.Visible = False
UserForm3.Show
Else
If reponse = "" Then
Exit Sub
Else
MsgBox ("Format date incorrect!")
Call BILANAGREAGE


End If

End If

End Sub

merci
dam
 

Pierrot93

XLDnaute Barbatruc
Re : Listbox avec plus de 10 colonnes

Re,

oui comme la plage de cellules n'est pas contigue, il y a lieu de passer par un tableau virtuel, regarde le code ci-dessous, à adapter à ton projet sans doute lieu de supprimer la 2ème boucle "for" si pas de critère permettant de déterminer d'une façon logique les numéros de colonne :
Code:
Option Explicit
Private Sub UserForm_Initialize()
Dim t(0 To 15, 0 To 19), l As Long, c As Long

For l = 0 To 15
    For c = 0 To 19
        t(l, c) = Cells(l + 1, c + 1)
    Next c
Next l

With ListBox1
    .ColumnCount = 20
    .List = t
End With
End Sub

bon après midi
@+
 

Discussions similaires

Réponses
25
Affichages
760

Statistiques des forums

Discussions
312 467
Messages
2 088 678
Membres
103 915
dernier inscrit
VT14907