Stumper of a CheckBox??????

rkcim

Board Regular
Joined
Nov 19, 2003
Messages
87
Basically I am trying to do this

Sub(CheckBoxNumber as Integer)

Sheet1.CheckBox"CheckBoxNumber".Disabled = True
End Sub

Will this code work? If not how do I reference a CheckBox in that way?

My dilema is I have approx 5 checkboxes on a sheet, and supposing that all checkboxes are unchecked:
If I check CheckBox1 then that one does not get disabled. If the next check box I click is CheckBox 2 this will cause CheckBox1 to be disabled. The only way CheckBox1 will be enabled is if CheckBox2 is unchecked, which would enable CheckBox1 and allow it to be unchecked.
 

Some videos you may like

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

TryingToLearn

Well-known Member
Joined
Sep 10, 2003
Messages
723
Sounds like you are trying to invent OptionButtons. If one is checked, the others are not. :wink:
 

rkcim

Board Regular
Joined
Nov 19, 2003
Messages
87
No, its not option buttons that I am trying to do.

These CheckBoxes are all unchecked, and enabled
I check the following checkboxes in this random order:
CheckBox1
CheckBox4 'causes CheckBox1 to be disabled
CheckBox3 'causes CheckBox4 to be disabled
CheckBox2 'causes CheckBox3 to be disabled
CheckBox5 'causes CheckBox2 to be disabled

They are now all checked all are disabled except CheckBox5 which is the last one to be checked. If I wanted to uncheck CheckBox1 I would have to uncheck these checkboxes in this order:
CheckBox5 'causes CheckBox2 to be enabled
CheckBox2 'causes CheckBox3 to be enabled
CheckBox3 'causes CheckBox4 to be enabled
CheckBox4 'causes CheckBox1 to be enabled
CheckBox1

Now all checkboxes are unchecked and enabled. I am trying to find an easy way of doing this. Any ideas? :p

Also if I check, for example, only 3 out of the 5 CheckBoxes to check, and I close the program and load it back up I need to beable to find out which ones were checked in order.
 

residnt

Board Regular
Joined
Nov 19, 2002
Messages
168
Well you almost have the answer that you need. I've done this in the past and I've used this code.

Private Sub CheckBox14_Click()
If (CheckBox14.Value = True) Then
CheckBox15.Enabled = True
Else
CheckBox15.Enabled = False
End If

If (CheckBox14.Value = True) Then
CheckBox13.Enabled = False
Else
CheckBox13.Enabled = True
End If

End Sub

Now this had to be entering into each checkbox and alter for each.

Let me know if this worked.

Residnt
 

Watch MrExcel Video

Forum statistics

Threads
1,114,057
Messages
5,545,753
Members
410,704
Latest member
Cobber2008
Top