excelisfunusually
New Member
- Joined
- Jul 29, 2015
- Messages
- 22
I asked this question in a similar forum, but wanted to solicit others for their ideas as well. I have groups of checkboxes (not actually grouped programmatically) that should be checked when a button is clicked. Once checked an additional code should run.
I received one reply that maybe adding the code for the checkboxes to the button's code would solve the issue. It does if I run the code from the VBA editor, but when the button is clicked on the spreadsheet I only have checked boxes. No additional action. I have provided the modified code below:
Do you see anything that I am doing wrong?
Thanks!
Also posted here https://www.excelforum.com/excel-pr...en-clicked-but-not-when-button-clicks-it.html
I received one reply that maybe adding the code for the checkboxes to the button's code would solve the issue. It does if I run the code from the VBA editor, but when the button is clicked on the spreadsheet I only have checked boxes. No additional action. I have provided the modified code below:
Code:
Public s As IntegerSub Button1_Click()
If s = 0 Then
ActiveSheet.CheckBoxes("Check Box 2").Value = 1
If Range("I1").Value >= Range("H5").Value Then
Range("I5").Formula = "=$E5"
End If
If Range("J1").Value >= Range("H5").Value Then
Range("J5").Formula = "=$E5"
End If
If Range("K1").Value >= Range("H5").Value Then
Range("K5").Formula = "=$E5"
End If
If Range("L1").Value >= Range("H5").Value Then
Range("L5").Formula = "=$E5"
End If
If Range("M1").Value >= Range("H5").Value Then
Range("M5").Formula = "=$E5"
End If
If Range("N1").Value >= Range("H5").Value Then
Range("N5").Formula = "=$E5"
End If
If Range("O1").Value >= Range("H5").Value Then
Range("O5").Formula = "=$E5"
End If
If Range("P1").Value >= Range("H5").Value Then
Range("P5").Formula = "=$E5"
End If
If Range("Q1").Value >= Range("H5").Value Then
Range("Q5").Formula = "=$E5"
End If
If Range("R1").Value >= Range("H5").Value Then
Range("R5").Formula = "=$E5"
End If
If Range("S1").Value >= Range("H5").Value Then
Range("S5").Formula = "=$E5"
End If
If Range("T1").Value >= Range("H5").Value Then
Range("T5").Formula = "=$E5"
End If
ActiveSheet.CheckBoxes("Check Box 3").Value = 1
ActiveSheet.CheckBoxes("Check Box 4").Value = 1
ActiveSheet.CheckBoxes("Check Box 5").Value = 1
ActiveSheet.CheckBoxes("Check Box 6").Value = 1
ActiveSheet.CheckBoxes("Check Box 7").Value = 1
ActiveSheet.CheckBoxes("Check Box 8").Value = 1
ActiveSheet.CheckBoxes("Check Box 9").Value = 1
ActiveSheet.Shapes.Range(Array("Button 1")).Select
Selection.Characters.Text = "Uncheck All"
s = 1
ElseIf s = 1 Then
ActiveSheet.CheckBoxes("Check Box 2").Value = -4146
Range("I5:T5").Value = ""
ActiveSheet.CheckBoxes("Check Box 3").Value = -4146
ActiveSheet.CheckBoxes("Check Box 4").Value = -4146
ActiveSheet.CheckBoxes("Check Box 5").Value = -4146
ActiveSheet.CheckBoxes("Check Box 6").Value = -4146
ActiveSheet.CheckBoxes("Check Box 7").Value = -4146
ActiveSheet.CheckBoxes("Check Box 8").Value = -4146
ActiveSheet.CheckBoxes("Check Box 9").Value = -4146
ActiveSheet.Shapes.Range(Array("Button 1")).Select
Selection.Characters.Text = "Check All"
s = 0
End If
End Sub
Do you see anything that I am doing wrong?
Thanks!
Also posted here https://www.excelforum.com/excel-pr...en-clicked-but-not-when-button-clicks-it.html
Last edited by a moderator: