Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Userform Question
Greetings,
I have a userform that changes the contents of the highlighted cell. I have a message box routine which confirms that the desired cell is highlighted (so we don't work on the wrong cell). At times, this gets laborous. What I would like to do is add a checkbox to the userform. Then when you open the workbook and run the userform you would go through the cell confirmation question. Then, when the userform pops up, if you don't want to go through the cell confirmation, you would check the checkbox. Once the checkbox is checked, the programming would remember this until you uncheck the checkbox or close the workbook. I can do all of the programming, however, I need an easy way to have the programming remember whether the checkbox is checked, and initially start unchecked. Any ideas on how to do this. In other languages there were volatile memory variables which remained available until the program was shutdown. It appears that these exist in VB, however, they only last while a module is running. Thanks for helping me understand!! Ray |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Userform Question
Hi,
How about a global boolean variable that sets the value of the checkbox on form loading and gets set by the checkbox on unloading? You could set it in ThisWorkbook module (I think).... Hth, OJ |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Userform Question
In the ThisWorkbook module place it outside of any sub, and at the very top:
---------------------------------- Option Explicit 'Declare the variable Checked for use in all procedures: Public Checked as Boolean ---------------------------------- Private sub....................... "OJ" wrote: Hi, How about a global boolean variable that sets the value of the checkbox on form loading and gets set by the checkbox on unloading? You could set it in ThisWorkbook module (I think).... Hth, OJ |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Userform Question
Not ThisWorkbook, as that is a class module. Put it in a general code
module. -- HTH RP (remove nothere from the email address if mailing direct) "OJ" wrote in message oups.com... Hi, How about a global boolean variable that sets the value of the checkbox on form loading and gets set by the checkbox on unloading? You could set it in ThisWorkbook module (I think).... Hth, OJ |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Userform Question
This worked fine. I found it best to create a new module and put the public
variables there. As you said, it doesn't work if you put the public variables in the same module. Thanks again!! Bob Phillips wrote in message ... Not ThisWorkbook, as that is a class module. Put it in a general code module. -- HTH RP (remove nothere from the email address if mailing direct) "OJ" wrote in message oups.com... Hi, How about a global boolean variable that sets the value of the checkbox on form loading and gets set by the checkbox on unloading? You could set it in ThisWorkbook module (I think).... Hth, OJ |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Userform Question
You could also create a workbook name that holds the value
set it with ActiveWorkbook.Names.Add name:="cbVal", RefersTo:=myVar1 get it with myVar1 = Evaluate(ActiveWorkbook.Names("cbVal").RefersTo) Or even more simply, never unload the form until the workbook closes, just hide it, that way the checkbox value is maintained at all times. -- HTH RP (remove nothere from the email address if mailing direct) "Ray Batig" wrote in message nk.net... Greetings, I have a userform that changes the contents of the highlighted cell. I have a message box routine which confirms that the desired cell is highlighted (so we don't work on the wrong cell). At times, this gets laborous. What I would like to do is add a checkbox to the userform. Then when you open the workbook and run the userform you would go through the cell confirmation question. Then, when the userform pops up, if you don't want to go through the cell confirmation, you would check the checkbox. Once the checkbox is checked, the programming would remember this until you uncheck the checkbox or close the workbook. I can do all of the programming, however, I need an easy way to have the programming remember whether the checkbox is checked, and initially start unchecked. Any ideas on how to do this. In other languages there were volatile memory variables which remained available until the program was shutdown. It appears that these exist in VB, however, they only last while a module is running. Thanks for helping me understand!! Ray |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Userform question | Excel Discussion (Misc queries) | |||
Userform question | Excel Discussion (Misc queries) | |||
Userform Question | Excel Discussion (Misc queries) | |||
Userform Question | Excel Programming | |||
Userform Question | Excel Programming |