|
-
February 22nd, 2000, 11:18 AM
#1
Checking for user input in an Excel Macro
I want to be able to check to see if a user has pressed a 'Stop' button
when I am running a query using VBA and populating an Excel Spreadsheet.
Excel seems to hang up whilst I'm in the macro.
Is there any sort of functionality that allows this type of thing?
Regards,
James.
-
February 22nd, 2000, 12:05 PM
#2
Re: Checking for user input in an Excel Macro
If your code takes a long time to run, you can place DoEvents at places in your code to return control to the system and allow messages to process.
Dim bQuitNow as Boolean
Sub MyLongRunningSub()
bQuitNow = false 'Initialize bQuitNow
'Do some actions that take a long time
DoEvents
If bQuitNow = true then
'Clean Up and get Out
End If
'Do some more things
DoEvents
If bQuitNow = true then
'Clean Up and get Out
End If
'etc...
End Sub
private Sub cmdStop_Click()
bQuitNow = true
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|