creating a variable on initializing a form.

medic5678

Board Regular
Joined
Nov 13, 2018
Messages
67
High everyone. First post :).

I'm working with a form that has many checkboxes. Because of the interaction between these, I need to not have the checkbox code execute when I click another checkbox that changes the value of the first checkbox. So I've created another variable and test it when the checkbox click event is fired. If I didn't click the checkbox, but it's being changed by another checkbox _Click routine, no code is executed.. thus nullifying the fact that the event is firing when I change the value.

The problem I'm having is declaring the variable when I initiate the form. It seems like the code within the

Private Sub CheckBox1_Click()

End Sub

cannot see the value of the variable. I get no error messages, but instead generate infinite loops that execute between two checkboxes which are changing each other's values. When I initiate the variable in a module, it works without a problem. However, since I don't use the variable anywhere else except in that form, it would make more sense to me to

dim clicked = boolean
clicked = false

When I actually create the form, use it while the form is open, then have it destruct when I close the form. So the issue is scope.

Any help appreciated. I've only been playing with excel for a few weeks, so of course I have a million newbie questions, this being the first :). Using Excel 2016.
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
If you want to use the variable throughout the userform module declare it at the top of the module outwith any subs/functions.
 
Upvote 0

Forum statistics

Threads
1,213,557
Messages
6,114,287
Members
448,562
Latest member
Flashbond

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