Adding CheckBoxes to a VBA Form
Posted on 2011-02-21
Ive been trying to add a bunch of checkboxes to a form Ive created in an Excel spreadsheet, I want to draw the checkboxes during run-time as the text and quantiy will change.
The code Ive done so far, which Ive putin UserForm_Activate() looks ok:-
Dim x As Integer
For x = 1 To 100 Step 1
Dim newCheckBox As CheckBox
newCheckBox.Text = "Hello " & x
newCheckBox.Top = x * 30
newCheckBox.Left = 10
However when it runs the line 'newCheckBox.Text = "Hello " & x' I get the error 'Run time error '91': Object variable or With block variable not set', but cant see anything thats not set.
Can anyone else see what I need to set to set a new checkbox up and add it to the controls on the form?