Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 111
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 252
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Userform question ub Excel Discussion (Misc queries) 0 February 19th 09 06:56 PM
Userform question Greg B Excel Discussion (Misc queries) 1 May 13th 05 01:06 PM
Userform Question Greg B Excel Discussion (Misc queries) 3 March 10th 05 10:46 AM
Userform Question Ryan Excel Programming 2 April 30th 04 02:48 AM
Userform Question Tom Ogilvy Excel Programming 4 April 26th 04 09:31 PM


All times are GMT +1. The time now is 03:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"