Control checkboxes

N

Newbeetle

Hi I have five check boxes from the control menu, these are named Checkbox1
through to 5.

When checkbox1 is unchecked I would like checkbox2 through to 5 to become
unchecked and grayed out.

When checkbox1 is ticked I would like checkbox2 through to 5 to become
active so that I can check them as required.

Hope that makes sense

Regards

Newbeetle
 
M

Mauro Gamberini

Try:

Private Sub CheckBox1_Click()

Dim s As String
Dim c As Control
Dim lng As Long

For lng = 2 To 5

s = "CheckBox" & lng
If Me.CheckBox1.Value = True Then
Me.Controls(s).Enabled = True
Else
Me.Controls(s).Enabled = False
End If
Next

End Sub


Private Sub UserForm_Initialize()

Dim c As Control
Dim lng As Long
Dim s As String

For lng = 2 To 5
s = "CheckBox" & lng
Me.Controls(s).Enabled = False
Next

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top