Pause macro for user task then continue...

TTom

Well-known Member
Joined
Jan 19, 2005
Messages
518
For broader discussion that included opening workbook option see:
"Puase macro to allow user to open/activate a WB, continue"
It got a bit long and I wanted to focus one one part, so...

I looking for a simplistic way to pause my macro while the user activates another workbook, once manually activated, the macro continues.

I found some code that might be useful in another forum.
The code allows a mouse click to exit. In my case I might be able to modify to have mouse click goto another part of my proceedure.
(the mouse click would be task of activating another workbook.)
My problem is I do not understand all of the code, I could use clarification on what 'set flag' and 'DoEvents' is and how I might use it.

Any takers on this?

<code>
Private Sub cmdCancel_Click()
Dim m_fCancelIsClicked As Boolean
' set the flag
m_fCancelIsClicked = True
End Sub

Private Sub LongSubRoutine()
Dim m_fCancelIsClicked As Boolean

Do While True
' body of loop
DoSomethingHere

' this line enables the GUI to look for a
' mouse click
DoEvents

' now look for the flag
' and leap out if necessary
If m_fCancelIsClicked Then Exit Do

Loop

End Sub
</Code>
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Forum statistics

Threads
1,214,411
Messages
6,119,360
Members
448,888
Latest member
Arle8907

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top