1

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?

3
  • Is your checkbox named CheckBox1? How about Sheet1.CheckBox? Is it an activeX checkbox, or a form control checkbox? Commented Jun 29, 2016 at 19:06
  • ActiveX control and I tried sheet("BalanceSheet").checkbox1. Still having issue. It also is the activesheet. Commented Jun 29, 2016 at 19:08
  • And you are certain it's named Checkbox1? Other than that, I don't see anything wrong with the code. Commented Jun 29, 2016 at 19:12

2 Answers 2

2

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)

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

Comments

-1

Try:

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

3 Comments

this is Excel not access vba - I believe I need to pass the sheet name...
Me is fine to use in Excel VBA, however, it's superfluous in this instance. If this code is in the worksheet's vba code, then it will work. If the code is in a module, then me would be referencing the module.
Did you look at this forum at all? - mrexcel.com/forum/excel-questions/…

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.