How do I refer to a checkbox (on a worksheet) in a class module?

phil152003

Board Regular
Joined
Mar 11, 2011
Messages
89
I have a checkbox on a worksheet (inserted by using the control toolbox). The checkbox itself does exactly what I want it to.

However, I have a class module (taken from another website site and works 99% what I need it to, except for this problem I have), and part of the code needs to depend on what the value of the checkbox is.

For example,

the checkbox is called "checkbox1" on "sheet1".

In my Class Module, I want to say

If checkbox1 (on sheet1) = True Then
<TRUE scenario>
Else
<FALSE scenario>
End If.

However, I'm obviously not referring to the checkbox right as it always ends up in the false scenario, regardless of the value of the checkbox.

I'm very new to vba, so apologies if this is reasonably simple.


EDIT: I should say, that is obviously nothing like the actual code I'm using. Just a large simplification as to avoid over-complication of what I think is a simple issue.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
That was exactly what I wanted, thanks! I tried something similar, but I was guessing at

Sheets("Sheet1").Object("Checkbox1").Value = True.

Obviously that isn't correct. But now I know! Again, thanks for your help.
 
Upvote 0

Forum statistics

Threads
1,224,548
Messages
6,179,451
Members
452,915
Latest member
hannnahheileen

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