vba syntax for excel object

  • Thread starter Thread starter TKoel
  • Start date Start date
T

TKoel

I want my VBA code to be able to reference the value of a check box on a
worksheet but I can't get the right syntax for the routine to recognize the
object. Simple, right? Help!
The object, called, say, "workBut" lists this in the formula bar -
"=EMBED("Forms.CheckBox.1","") What could that possibly mean. Is it a clue?
 
You can use code like the following:


Dim ChkBox As MSForms.CheckBox
Set ChkBox = Worksheets("Sheet1").OLEObjects("CheckBox1").Object
If ChkBox.Value = False Then
Debug.Print "not checked"
Else
Debug.Print "checked"
End If

Change Sheet1 to the appropriate sheet name and change CheckBox1 to
the appropriate control name.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top