Bonjour,

En parcourant le site j'ai trouvé un excellent tuto pour faire des en-têtes à une listbox -->Un grand Merci à SilkyRoad.
Mon souci est que je n'ai pas su adapter le code pour définir non seulement la plage (A1;F3000)mais aussi la feuille pour la base de données .
Help!

Merci à vous.

Voici le code:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
Private Sub UserForm_Initialize()
    Dim Plage As Range
    Dim Tableau As Variant
    Dim i As Integer
    Dim Lbl As Control
 
    'Plage de cellules contenant les données:
    'Le contenu de la première ligne (A1:C1) va servir d'en-tête.
    Set Plage = Range("A1:f3000")
    Tableau = ScindePlage(Plage)
 
    With ListBox1
        .ColumnCount = UBound(Tableau, 2)
        'En option (à adapter)
        .Top = 20
        .Width = 92 * UBound(Tableau, 2)
        DoEvents
        .List() = Tableau
    End With
 
 
    For i = 1 To UBound(Tableau, 2)
        Set Lbl = Me.Controls.Add("Forms.Label.1")
        With Lbl
            .Left = ListBox1.Left + 7 + ((i - 1) * 92)
            .Top = ListBox1.Top - 10
            .Width = 92
            .Height = 10
            .Caption = Plage.Cells(1, i)
        End With
    Next i
 
End Sub
 
Function ScindePlage(Cible As Range) As Variant
    Dim Pl As Range
 
    Set Pl = Cible.Offset(1, 0).Resize(Cible.Rows.Count - 1)
    ScindePlage = Pl.Value
End Function