Compile Error on checkbox in command button

talt0612

New Member
Joined
Nov 22, 2011
Messages
35
Hi all- I need some help on a (hopefully) simple problem. I have a sheet that contains an activex command button and several checkboxes. when I click the command button I get a "Compile error: Method or data member not found" at this point:

Code:
HedgeSheet.CheckBox3.Visible = True

and ".CheckBox3" is highlighted in blue. Note that HedgeSheet is set as
Code:
"Thisworkbook.Sheets("HedgeSheet")

If I run the same code with a form button, everything works as expected.
Note: I'd like to use the activex button if possible because the sheet is for a client and there are more formatting options w/ the activex.
Thanks in advance,
T
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Posting one line of code doesn't help understanding/tracking the source of error. Please post the full code or sample workbook.

Meanwhile, check that all referenced controls exist.
 
Upvote 0
You can't refer to a control on worksheet like that.

If this code was in the worksheet module you could just use CheckBox3 on it's own.

Outside that module there are different ways to refer to it.

Perhaps the simplest is this where Sheet1 is the codename (not the tab name) of the worksheet the checkbox is on.
Code:
Sheet1.CheckBox3

Here's an exampel that uses the tab name.
Code:
Worksheets("HedgeSheet").OLEObjects("CheckBox3")
 
Upvote 0

Forum statistics

Threads
1,215,521
Messages
6,125,308
Members
449,218
Latest member
Excel Master

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top