Karen Schaefer
Karen Schaefer

Reputation: 107

Excel use Checkbox in vba

I need to verify if an activex checkbox is checked in my vba code, however, when I try - " If Checkbox1.Value = True Then" it is asking for variable not defined. What am i missing?

Upvotes: 1

Views: 1987

Answers (2)

JB28
JB28

Reputation: 57

Try:

If Me.Checkbox1 = True Then
  'whatever code goes here
End If

Upvotes: -1

Gary's Student
Gary's Student

Reputation: 96753

How about:

Sub dural()
    If ActiveSheet.OLEObjects("CheckBox1").Object.Value = True Then
        MsgBox "it is checked"
    End If
End Sub

enter image description here

Note this is for a "standalone" ActiveX checkbox (not on a userform)

Upvotes: 2

Related Questions