Pausing a macro during execution
I have a macro that moves some objects around on a spreadsheet to
simulate a process. It has a start and stop time it is set to run. What I would like to do is be able to hit the ESC or some other hey while the macro(s) are processing, it would stop where it is at and then if I hit the button again it would continue. I dont want the VB message box that says "code execution has been interrupted" to pop up and take me to the VB editor. I just want a simple pause. I am thinking there has to be some way to look for key stokes and then if a certian one is encountered be able to pause until it is hit again. Thanks Scott RIddle |
Pausing a macro during execution
This is not exactly what you are looking for but it is close. Hitting the Esc
key will pause execution... Public Sub PauseMacroIsh() Dim lng As Long Application.EnableCancelKey = xlErrorHandler On Error GoTo ErrorCleanUp For lng = 1 To 100000 Application.StatusBar = lng Next lng ErrorCleanUp: If Err = 18 Then MsgBox "macro has been paused" Resume Else Application.StatusBar = False End If End Sub -- HTH... Jim Thomlinson "Scott" wrote: I have a macro that moves some objects around on a spreadsheet to simulate a process. It has a start and stop time it is set to run. What I would like to do is be able to hit the ESC or some other hey while the macro(s) are processing, it would stop where it is at and then if I hit the button again it would continue. I dont want the VB message box that says "code execution has been interrupted" to pop up and take me to the VB editor. I just want a simple pause. I am thinking there has to be some way to look for key stokes and then if a certian one is encountered be able to pause until it is hit again. Thanks Scott RIddle |
All times are GMT +1. The time now is 06:04 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com