R
ryguy7272
This is a bit complex, so let me take a moment to explain. I’m trying to
open a ‘template’ and connect the code to a button so a user can click it and
put a ‘1’ in cell Z16, then put an OptionButton in A16 and another
OptionButton in B16, then assign an identifier to these OptionButtons (a name
or a value to identify these objects). Then a row is inserted at row 17.
Then if the user clicks the button again, a 2 goes into Z17, and an
OptionButton goes into A16 and another OptionButton goes into B17, these are
identified (somehow) and a row is inserted at row 18. If the user clicks the
button again, a 3 goes into Z18, and . . . so on and so forth.
Here’s the code I have now.
Private Sub CommandButton3_Click()
Dim optBtn As OptionButtons
Range("Z16").Select
ActiveCell.Value = 1
i = 5
For i = 1 To j
ActiveSheet.OptionButtons.Add ActiveCell.Offset(0, -26).Left,
ActiveCell.Top, ActiveCell.Width, ActiveCell.Height
ActiveSheet.OptionButtons.Add ActiveCell.Offset(0, -25).Left,
ActiveCell.Top, ActiveCell.Width, ActiveCell.Height
ActiveCell.Selection.EntireRow.Insert
Set WS = Application.ActiveWorkbook.Worksheets("Worksheet")
With Targe
optBtn.Caption = ""
optBtn.GroupBox.Name = strGroupName & j
End With
Next i
End Sub
What am I doing wrong?
Thanks!
Ryan
open a ‘template’ and connect the code to a button so a user can click it and
put a ‘1’ in cell Z16, then put an OptionButton in A16 and another
OptionButton in B16, then assign an identifier to these OptionButtons (a name
or a value to identify these objects). Then a row is inserted at row 17.
Then if the user clicks the button again, a 2 goes into Z17, and an
OptionButton goes into A16 and another OptionButton goes into B17, these are
identified (somehow) and a row is inserted at row 18. If the user clicks the
button again, a 3 goes into Z18, and . . . so on and so forth.
Here’s the code I have now.
Private Sub CommandButton3_Click()
Dim optBtn As OptionButtons
Range("Z16").Select
ActiveCell.Value = 1
i = 5
For i = 1 To j
ActiveSheet.OptionButtons.Add ActiveCell.Offset(0, -26).Left,
ActiveCell.Top, ActiveCell.Width, ActiveCell.Height
ActiveSheet.OptionButtons.Add ActiveCell.Offset(0, -25).Left,
ActiveCell.Top, ActiveCell.Width, ActiveCell.Height
ActiveCell.Selection.EntireRow.Insert
Set WS = Application.ActiveWorkbook.Worksheets("Worksheet")
With Targe
optBtn.Caption = ""
optBtn.GroupBox.Name = strGroupName & j
End With
Next i
End Sub
What am I doing wrong?
Thanks!
Ryan