ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Control checkboxes (https://www.excelbanter.com/excel-programming/389657-control-checkboxes.html)

Newbeetle

Control checkboxes
 
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


--
This post was created using recycled electrons!

Mauro Gamberini[_3_]

Control checkboxes
 
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

--
---------------------------
Mauro Gamberini
http://www.riolab.org/
"Newbeetle" ha scritto nel messaggio
...
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


--
This post was created using recycled electrons!





All times are GMT +1. The time now is 12:11 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com