Private Sub CommandButton1_Click()
With Sheets("Feuil2")
For i = 1 To 5
.Range("A" & .Rows.Count).End(xlUp).Offset(1, 0) = Me.Controls("textrad" & i - 1)
.Range("A" & .Rows.Count).End(xlUp).Offset(0, 1) = Me.Controls("CB" & i - 1)
Next i
End With
End Sub
Private Sub UserForm_initialize()
b = Sheets("feuil1").Cells(1, 1).Value
For i = 1 To b 'Création des labels avec les noms de la feuille
Set rad = UserForm1.Controls.Add("forms.Label.1")
With rad
nom = "textrad" & i - 1
.Name = nom
.Left = 138
.Top = 159 + i * 30
.Width = 140
.Height = 24
.Caption = Sheets("feuil1").Cells(i, 4).Value
.TextAlign = 2
End With
Next i
For i = 1 To b 'création des Combobox
Set rad = UserForm1.Controls.Add("forms.combobox.1")
With rad
.Name = "CB" & i - 1
.Left = 300
.Top = 153 + i * 30
.Width = 140
.Height = 20
.Value = Sheets("feuil1").Cells(i, 5).Value
.TextAlign = 2
End With
Next i
End Sub
'https://forum.hardware.fr/hfr/Programmation/VB-VBA-VBS/creation-textbox-dynamique-sujet_104861_1.htm