|
-
Mar 20th, 2013, 08:02 AM
#1
Thread Starter
New Member
[RESOLVED] MS Excel 2007, Disable/Enable Checkboxes based upon cell value
I am trying to make it so when cell F15 (which has a list data validation) is set to "Off", that checkboxes 19, 20 and 21 are disabled. When F15 is on anything else, the boxes are enabled. My code is below.
It disables it always, regardless of the value.
I have a feeling it is what i named my sub as, but I am relatively new to VBA and cannot find how to appropriately name it. Any help would be appreciated. Thanks!
Code:
Sub Worksheet_Activate()
If (Sheets("Generator").Range("F15").Value = "Off") Then
Sheets("Generator").CheckBoxes("Check Box 19").Enabled = False
Sheets("Generator").CheckBoxes("Check Box 20").Enabled = False
Sheets("Generator").CheckBoxes("Check Box 21").Enabled = False
Else
Sheets("Generator").CheckBoxes("Check Box 19").Enabled = True
Sheets("Generator").CheckBoxes("Check Box 20").Enabled = True
Sheets("Generator").CheckBoxes("Check Box 21").Enabled = True
End If
End Sub
-
Mar 20th, 2013, 10:21 AM
#2
Thread Starter
New Member
Re: MS Excel 2007, Disable/Enable Checkboxes based upon cell value
I resolved this one myself. IF anyone is intersted in the code here it is:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range
Set KeyCells = Range("F15")
If Not Application.Intersect(KeyCells, Range(Target.Address)) = "Off" Then
Sheets("Generator").CheckBoxes("Check Box 19").Enabled = True
Sheets("Generator").CheckBoxes("Check Box 20").Enabled = True
Sheets("Generator").CheckBoxes("Check Box 21").Enabled = True
Else
Sheets("Generator").CheckBoxes("Check Box 19").Enabled = False
Sheets("Generator").CheckBoxes("Check Box 20").Enabled = False
Sheets("Generator").CheckBoxes("Check Box 21").Enabled = False
End If
End Sub
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|