Dim Nomfeuille1 As String
Private Sub CommandButton1_Click()
Dim Dl1 As Long ' dernière ligne
Dim col As Long
Dim i As Long
If Me.ComboBox1.ListIndex = -1 Then Exit Sub
With Sheets(Nomfeuille1)
col = CLng(ComboBox1.List(ComboBox1.ListIndex, ComboBox1.ColumnCount - 1))
Dl1 = .Cells(Columns(col).Cells.Count, col).End(xlUp).Row + 1 ' avec numéro de colonne
For i = o To Me.ListBox1.ListCount - 1
.Cells(Dl1, col) = Me.ListBox1.List(i)
Dl1 = Dl1 + 1
Next i
End With
End Sub
......................................
Private Sub UserForm_Initialize()
'Me.ComboBox1.List = Application.Transpose(Range("choix"))
Dim col As String
Dim cellule As Range
Dim Ligdep As Integer
Dim dc1 As Long
'paramètre
col = "a"
Nomfeuille1 = "Feuil1"
Ligdep = 5
'
With ComboBox1
.Clear
.ColumnCount = 2
.ColumnWidths = "60;0;0"
.Style = fmStyleDropDownList '
'.Width = 100
'.BoundColumn = 1 ' combobox1.text contient le nom
dc1 = Sheets(Nomfeuille1).Cells(1, Rows(1).Cells.Count).End(xlToLeft).Column
For Each cellule In Sheets(Nomfeuille1).Range(Cells(1, 1), Cells(1, dc1))
.AddItem cellule.Value
.List(.ListCount - 1, .ColumnCount - 1) = cellule.Column
Next cellule
End With
'col = CLng(ComboBox1.List(ComboBox1.ListIndex, ComboBox1.ColumnCount - 1))
With Me.ListBox1 'evite de répéter cette expression devant les Points
.ColumnCount = 1 'on affecte 8 colonnes à la listBox
.ColumnWidths = "40;" 'largeurs colonnes
End With
End Sub