Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Check button

Hi,

I am running a long process and would the user to be able to stop/cancel the
process.
I can put a button on the sheet or one a userform but what code do I need to
insert in my process to detect if the button gets clicked?

Thanks
Fred


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Check button

This great little piece of code is a good tutorial for nearly any
called process where one has to make sure that no recursive looping
occurs, which could be a bad thing.

I can make a list of checkboxes that the button code can test the values
of and incorporate into its process pathways. "TheProcessFlag" can be
anything. The button click can call the checkbox tests and then decide at
which point in the code to continue or call new code. It is like an
if/then thing without so much if/then coding.

A cool little decision engine.

Thanks.



On Wed, 14 Apr 2010 19:44:01 -0700, JLatham
wrote:

Start by declaring a public Booleann variable. We'll call it
stopTheProcessFlag.

At the beginning of your long process, set that flag = False.

Within your process, at appropriate locations, test to see if it has changed
to True and if so, gracefully abort the process (assuming that's what you
want to do when someone clicks the button).

For this one, I'd recommend a command button from the Controls Toolbox.
Once you put it on the sheet, double-click on it to open up the VB Editor to
its _Click event code.

Private Sub CommandButton1_Click()
stopTheProcessFlag = True
End Sub

Or if you want subsequent clicks of the button to toggle the flag:
Private Sub CommandButton1_Click()
stopTheProcessFlag = Not stopTheProcessFlag
End Sub

"Fred" wrote:

Hi,

I am running a long process and would the user to be able to stop/cancel the
process.
I can put a button on the sheet or one a userform but what code do I need to
insert in my process to detect if the button gets clicked?

Thanks
Fred


.

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
Option Button versus Check Box Mary Lou[_2_] Excel Programming 3 October 14th 09 12:53 AM
Check Box and Button Macros SweetTea023 New Users to Excel 1 June 18th 09 08:36 PM
Combining use of Check Box and Option Button Erol Excel Worksheet Functions 0 April 29th 09 10:16 PM
Check Box or Button Help Snipeston Excel Programming 1 May 31st 07 02:09 PM
Check Existing Button Mike[_101_] Excel Programming 1 October 27th 05 05:39 PM


All times are GMT +1. The time now is 07:05 PM.

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"