samedi 30 juillet 2016

VBA CheckBox Not Checked If Statement Won't Initiate

this super simple thing is currently driving me crazy. I have an If statement to handle the CheckBox_Click() event which is supposed to do one of two things depending on the status of the CheckBox. While it works just fine when the box becomes checked, it just won't do anything when the box is unchecked. I know the code is firing simply by putting a MsgBox to tell me, but the If statement won't initiate. See code below:

Sub Chase_Visa_Click()
    'Check new button status for action.
    If Sheets("<Sheet Name>").Shapes("<CheckBox Name>").OLEFormat.Object.Value = 1 Then
        MsgBox ("Box checked.")
    ElseIf Sheets("<Sheet Name>").Shapes("CheckBox Name>").OLEFormat.Object.Value = 0 Then
        MsgBox ("Box unchecked.")
    End If
End Sub

From what I've read, the value for unchecked is 0. I've also tried things like ".Checked = False". Thank you very much for your help.




Aucun commentaire:

Enregistrer un commentaire