CheckBox checked and unChecked

  • Hi there

    I placed a checkbox from control toolbox on a sheet
    i put a code in the Private Sub CheckBox1_Click()........
    So whenever i check the box the code excuted .

    i want the checkbox to be unchecked when the code complete it i can check the checkbox again to run the code again

    How can i do this ? :roll:

  • Re: CheckBox checked and unChecked

    You can use

    CheckBox1.Value = False

    This will set the value to unchecked, but be aware by doing this you are making a recursive call back to the click event of the checkbox so any code you have will run twice. You would need to set up something to keep it from doing so.

  • Re: CheckBox checked and unChecked

    Perhaps something like this.

    Private Sub CheckBox1_Click()
        If CheckBox1 Then
            MsgBox "Box checked"
            CheckBox1 = Not CheckBox1
        End If
    End Sub

    By the way why are you using a checkbox to run code? Why not use a command button?

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!