Form Control Checkboxes (Not ActiveX Controls )

rameezl17

Board Regular
Joined
Mar 6, 2018
Messages
105
Hi Everyone,

I'm still new to coding and looking to learn more. One thing I can't figure out and I'm 100% sure its so easy. I am doing this through a Form Control because I know that ActiveX controls on an excel sheet causes resizing when the screen resolution changes.

So I have a Checkbox that says "Yes?" Named (CheckBox1). The Macro I assigned to it is that when you click on the checkbox it opens up "UserForm1". So the Code is straightforward.

Sub CheckBox1_Click()
UserForm1.Show
End Sub

That works fine, however when I go to uncheck the checkbox in the excel sheet, it causes UserForm1 to open again and then the "Yes?" Checkbox is unchecked. How can I make it so that when I uncheck the checkbox it doesn't show UserForm1, just unchecks the checkbox?

(I thought maybe if I do a Yes and No Checkbox If Checkbox "Yes?" Is Clicked (CheckBox1) Then Checkbox "No?"(CheckBox2) will be unchecked automatically . I'm Not sure what's the best way to get this done, but I am struggling to figure it out.


If it helps. The scenario is just a Yes Or No Question Answer. So If you click Yes, it opens up a userform, but if you click No a msgbox opens up to tell you to move on to the next question.

Thank you so much for your help!
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
@HackSlash, I fear you may have gotten the wrong end of the stick. These are forms controls on sheets.

The code you're looking for is:
Rich (BB code):
Public Sub CheckBox1_Click()
    If ActiveSheet.CheckBoxes(Application.Caller) = 1 Then
        UserForm1.Show
    End If
End Sub
 
Last edited:
Upvote 0
Is it definitely a forms control? If expect that with activex

You're not using a Mac are you?
 
Last edited:
Upvote 0
Yes it is a form control.
No I am not using a Mac.

They prolly with the checkboxes is that I get it to work fine. I just hate the fact that if I try to uncheck the checkbox it causes the userform to open up first (which then you have to close the userform) and then it unchecks the box.
 
Upvote 0
On which line do you get that error? I have this working with the exact code I posted on my screen right now.
 
Upvote 0
I get an error on the first line after Sub CheckBox1_Click()

Is it because the button is on a excel spreadsheet?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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