ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   userform multitask ? (https://www.excelbanter.com/excel-programming/366226-userform-multitask.html)

Nicodemus

userform multitask ?
 
hello,

I wish to be able to click a button on my userform while the code is
running, and when the button is clicked to run another module.
example : a loop would check each cell from column A, and when the user
would click a "Pause" button, the loop would stop until the user click a
"Play" button.

Is this possible ?

RB Smissaert

userform multitask ?
 
Yes, you can do that.

for example:

for i = 1 to 1000
DoEvents
If bPause then
Do While bPause = True
DoEvents
Loop
end if
'run code here
Loop

In a button:
bPause = True

In other button:
bPause = False

The essential bit are the DoEvents statements, so it can respond to your
button clicks.

RBS


"Nicodemus" wrote in message
...
hello,

I wish to be able to click a button on my userform while the code is
running, and when the button is clicked to run another module.
example : a loop would check each cell from column A, and when the user
would click a "Pause" button, the loop would stop until the user click a
"Play" button.

Is this possible ?



Nicodemus

userform multitask ?
 
Great. It works perfectly !

Thank you for this fast & efficient response.

Nicodemus

"RB Smissaert" wrote:

Yes, you can do that.

for example:

for i = 1 to 1000
DoEvents
If bPause then
Do While bPause = True
DoEvents
Loop
end if
'run code here
Loop

In a button:
bPause = True

In other button:
bPause = False

The essential bit are the DoEvents statements, so it can respond to your
button clicks.

RBS


"Nicodemus" wrote in message
...
hello,

I wish to be able to click a button on my userform while the code is
running, and when the button is clicked to run another module.
example : a loop would check each cell from column A, and when the user
would click a "Pause" button, the loop would stop until the user click a
"Play" button.

Is this possible ?





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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com