This is my code. I am trying to use a variable that increases on each loop that will get the next value from the worksheet. I hope that I put the code in the correct way.
Private Sub UserForm_Initialize()
Dim startoption1 As Variant
Dim lastrow As Integer
Dim opt As Variant
Dim a As Integer
Dim inputbutton As Variant
Dim radioname As String
a = 1
lastrow = Sheets("start options").Range("a" & Rows.Count).End(xlUp).Row
For a = 1 To lastrow
startoption1 = Sheets("start options").Cells(a, 1)
inputbutton = "OptionButton." & a
'msgbox inputbutton outputs OptionButton.1 then OptionButton.2 OptionButton.3 OptionButton.4 OptionButton.5 etc.........
radioname = "radioname" & a
' problem is with inputbutton. If I replace that with OptionButton.1 then it will work,but only with one button.
'i may need to set inputbutton to something I am not sure what to set it as.
Set opt = UserForm1.Controls.Add("Forms.inputbutton", "radioname", True)
opt.Caption = startoption1
Next
End Sub
Bookmarks