0

The aim is if the checkbox next to the commandbutton "Examine 1" is activated manually the commandbutton "Examine 1" are supposed to be deactivated. Which means that if the overall Button "Execute all" is pushed then all other buttons below will be triggered one by one except the "Examine 1" Button. I have already written the Sub for the "Examine 1" Button and also for the checkBox 1. I just dont know how to get the Sub of the checkbox integrated into the "Examine 1" Sub. Currently, if I push the overall BUtton "Execute all" then the Button "Examine 1" is also executed no matter whether the checkbox is marked or not.

This is the macro of the "Examine 1" Button

Sub Examine_Click()
....
...

This one is Sub for the checkbox which refers to the Sub "Examine_Click()"

Private Sub CheckBox1_Click()

Dim b As Button

Set b = ActiveSheet.Buttons("Button 4")

If CheckBox1.Value = True Then
   b.Enabled = True
   b.Font.ColorIndex = 1
Else: b.Enabled = False
    b.Font.ColorIndex = 15

End If
End Sub

2 Answers 2

1

In your Checkbox code you are never enabling the button: If CheckBox1.Value = True Then: b.Enabled = False | Else: b.Enabled = False. But that's not the problem.

You state that the ExecuteAll button is supposed to call the Subs associated with the other buttons but I'm not sure that the b.Enabled property will prevent the Sub call from running, it will only disable the user's click. In the ExecuteAll_Click() you should test the relevant checkbox before executing the associated button's code.

Sign up to request clarification or add additional context in comments.

1 Comment

you are right. It was a typo. Just corrected it. To your second comment: the "b.Enabled" property doesnt prevent the Sub from running, this is exactly my point. The aim is that the button is deactived and cannot be clicked if the checkmark is set in the checkbox.
0

the solution is:

 If Worksheets("Control").CheckBox1.Value = True Then

This means that if the checkbox is activated the main macro starts running, otherwise it jumps stright to "end sub"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.