Bonjour à tous,
je cherche à adapter ce code VBA ci dessous à ma situation(Mettre les entêtes ListBox via 1 Fram). Ma base de données elle comporte des éléments de A à K, mais je ne trouve pas comment le faire (à chaque fois j'ai un code erreur) celui-ci est pour une base de A à I
Merci de votre aide
Cordialement.
Private Sub UserForm_Initialize()
Dim NbCol
Set f = Sheets("BD1")
NbCol = f.[A1].CurrentRegion.Columns.Count
Me.ListBox1.ColumnCount = NbCol
Set plage = f.[A1].CurrentRegion
Set plage = plage.Offset(1).Resize(plage.Rows.Count - 1)
x = Me.ListBox1.Left + 8
y = Me.ListBox1.Top - 12
For i = 1 To NbCol
Set Lab = Me.Frame3.Controls.Add("Forms.Label.1")
Lab.Caption = f.Cells(1, i)
Lab.Top = y
Lab.Left = x
x = x + f.Columns(i).Width * 1.02
temp = temp & f.Columns(i).Width * 1.02 & ";"
Next
temp = Left(temp, Len(temp) - 1)
Me.ListBox1.ColumnWidths = temp
Me.Frame3.ScrollWidth = Me.ListBox1.Width + 10
Me.Frame3.ScrollBars = 1
Me.ListBox1.List = plage.Value