Checking a Check Box using VBA

NathanW

New Member
Joined
Jun 17, 2013
Messages
27
Hey everybody,

I'm just wondering if it's possible to check or uncheck a check box in VBA? If it is, I would really like to know how please =)
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Using a Form checkbox control

Code:
    ActiveSheet.Shapes.Range(Array("Check Box 1")).Value = xlOn

    ActiveSheet.Shapes.Range(Array("Check Box 1")).Value = xlOff
 
Upvote 0
Thank you very much for the response, but that doesn't seem to work for me. I get the error "Run-time error '438': Object doesn't support this property or method".
 
Upvote 0
May be because I'm in a different version of Excel so my macro recorder has different syntax. Go ahead and create a Checkbox form control, then record the macro, right click the checkbox (in design mode) and go to Format Control. On the Control tab set the value to on and then do it for off. Should give you the proper syntax for your environment.
 
Upvote 0
actually, my bad - I guess you have to select the checkbox before you can do anything with it.

Code:
    ActiveSheet.Shapes.Range(Array("Check Box 1")).Select
    With Selection
        .Value = xlOn
        .LinkedCell = ""
        .Display3DShading = False
    End With
 
Upvote 0
I had the same issue and this solution has helped me greatly, thank you.
 
Upvote 0

Forum statistics

Threads
1,214,644
Messages
6,120,709
Members
448,983
Latest member
Joaquim_Baptista

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