ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   vba syntax for excel object (https://www.excelbanter.com/excel-discussion-misc-queries/220200-vba-syntax-excel-object.html)

TKoel

vba syntax for excel object
 
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?

Chip Pearson

vba syntax for excel object
 

You can use code like the following:


Dim ChkBox As MSForms.CheckBox
Set ChkBox = Worksheets("Sheet1").OLEObjects("CheckBox1").Objec t
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)




On Tue, 10 Feb 2009 15:05:01 -0800, TKoel
wrote:

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?



All times are GMT +1. The time now is 03:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com