Fair warning I'm very new to using VBA and I've looked all over this site but I can't seem to a similar question.
I'm hoping it's a pretty easy solution though.
I have these checkboxes 1 - 4
Example of data
| Column A (CheckBox 1) | Column B (CheckBox2) | Column C (CheckBox3) | Column D (CheckBox4) | Column E Results |
|---|---|---|---|---|
| 1 | 4 | 7 | E1 | |
| 2 | 5 | 8 | E2 | |
| 3 | 6 | 9 | E3 |
Here's a summary of the necessary steps/ conditions
Checkboxes 1 - 3 affect each other and all three affect checkbox 4
- If one checkbox in this set of 3 is checked
then the other two are disabled
the checkbox will select a range in its corresponding column to populate to cells in column E
checkbox 4 is supposed to be disabled - If none of them are checked,
then checkbox 4 is checked
the cells in column E are all 0
So for example what should happen is that if I select CheckBox1 in column A, CheckBox2 ,3 and 4 will disable
The data in column A will transfer to column E
And if CheckBox 1 - 3 are not checked CheckBox4 will enable and automatically be checked while E1:E3 will be 0
Right now,
If I run the code the first time around and checkboxes 1 -3 are not clicked then checkbox 4 is clicked. GOOD!
If I click any of checkbox 1 -3, checkbox 4 is not clicked and it is disabled GOOD!
If I deselect checkbox 1 - 3 checkbox 4 is permanently disabled and does not reselect. BAD!
I can select a new checkbox in 1 - 3 and the other two will still disable and column E will change. GOOD!
here's my code so far
Private Sub CheckBox1_Click()
If CheckBox1.Value = True Then
CheckBox2.Value = False
CheckBox2.Enabled = False
CheckBox3.Value = False
CheckBox3.Enabled = False
CheckBox4.Value = False
CheckBox4.Enabled = False
Range("A1:A3").Value = Range("E1:E3").Value
Else:
CheckBox2.Enabled = True
CheckBox3.Enabled = True
End If
End Sub
Private Sub CheckBox2_Click()
If CheckBox2.Value = True Then
CheckBox1.Value = False
CheckBox1.Enabled = False
CheckBox3.Value = False
CheckBox3.Enabled = False
CheckBox4.Value = False
CheckBox4.Enabled = False
Range("B1:B3").Value = Range("E1:E3").Value
Else:
CheckBox1.Enabled = True
CheckBox3.Enabled = True
End If
End Sub
Private Sub CheckBox3_Click()
If CheckBox3.Value = True Then
CheckBox1.Value = False
CheckBox1.Enabled = False
CheckBox2.Value = False
CheckBox2.Enabled = False
CheckBox4.Value = False
CheckBox4.Enabled = False
Range("A1:A3").Value = Range("E1:E3").Value
Else:
CheckBox1.Enabled = True
CheckBox2.Enabled = True
End If
End Sub
Private Sub CheckBox9_Click()
If CheckBox1.Value = False And CheckBox2.Value = False And CheckBox3.Value = False Then
CheckBox4.Value = True
CheckBox4.Enabled = True
Range("E1:E3").Value = 0
Else:
CheckBox4.Value = False
CheckBox4.Enabled = False
End If
End Sub
"I tried using a loop code I found online for each sub which didn't work"
"And then I tried with just looping the end at checkbox 4
same thing checkbox permanently disabled."
Sub CheckboxLoop()
Dim objX As OLEObject
With ActiveSheet
For Each objX In .OLEObjects
End If
Next
End With
End Sub
I also tried deleting the CheckBox4.Enabled = False at various points in the code. Once I deleted it all except last Sub Private Sub CheckBox4_Click() and other times deleted just last sub but it would also just be stuck on disabled. Eventually I deleted all CheckBox4.Enabled = False but of course that means check box 4 won't disable.
Any help would be greatly appreciated.