Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How to get looping VBA code to respond to events on worksheet

Hello,

I have some code of the form

do while not g_Paused
bunch of calls
...
loop

where I'd like the variable g_Paused to be toggled by a button on the
worksheet. The only way I can seem to get the code to respond to the
button click is to use

do while not g_Paused
bunch of calls
...
ThisWorkbook.Worksheets("Name").Activate
DoEvents
loop

But this is pretty slow and causes the sheet to flicker...is there a
better method?


PS


I'm using buttons from the Control Toolbox


Thank you.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to get looping VBA code to respond to events on worksheet

A quick way is to create a userform, with a button that sets the
g_paused = true

open the form show(vbmodeless)

then before your loop do
application.screenupdating = false

after your button is pressed

application.screenupdating = true.



"monkeyboy" wrote:

Hello,

I have some code of the form

do while not g_Paused
bunch of calls
...
loop

where I'd like the variable g_Paused to be toggled by a button on the
worksheet. The only way I can seem to get the code to respond to the
button click is to use

do while not g_Paused
bunch of calls
...
ThisWorkbook.Worksheets("Name").Activate
DoEvents
loop

But this is pretty slow and causes the sheet to flicker...is there a
better method?


PS


I'm using buttons from the Control Toolbox


Thank you.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How to get looping VBA code to respond to events on worksheet

Sorry, I should have been more explicit. I have a button on the
worksheet that sets g_Paused to TRUE, then calls the loop procedure. I
also have an "Pause" button on the worksheet that sets g_Paused to
FALSE. Once I enter the loop procedure however, the code no longer
responds to buttons on the worksheet, unless I say
"ThisWorkbook.Worksheets("Name").Activate ". When in the IDE, it
appears as if the event is firing as I can see the worksheet module
flicker when I push the "Pause" button, but the global g_Paused
doesn't seem to be set to FALSE? I have my code arranged in several
modules, with PUBLIC procedures and PUBLIC globals. I'll try using a
Form, but I don't understand what is stopping the worksheet event from
setting the variable...
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
Getting .NET form to respond to Excel window events [email protected] Excel Programming 1 May 2nd 07 02:25 PM
Force event code to NOT respond Peter Danes Excel Programming 7 August 7th 06 03:12 PM
Worksheet events and a little bit extra code tinkerbellsmyhoe Excel Programming 3 April 27th 06 02:52 PM
worksheet tabs do not respond to grouping Cleared for Take-Off Excel Discussion (Misc queries) 3 November 1st 05 12:36 AM
excel.application.run macro1 -- added code to respond "yes" to a inputbox Michael Joe Excel Programming 3 August 13th 04 10:11 PM


All times are GMT +1. The time now is 08:41 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"