creating a variable on initializing a form.

medic5678

New Member
Joined
Nov 13, 2018
Messages
48
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.
 

Some videos you may like

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,559
Office Version
365
Platform
Windows
If you want to use the variable throughout the userform module declare it at the top of the module outwith any subs/functions.
 

Watch MrExcel Video

Forum statistics

Threads
1,099,030
Messages
5,466,121
Members
406,468
Latest member
Toto Li

This Week's Hot Topics

Top