ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   stop a macro (https://www.excelbanter.com/excel-programming/353336-stop-macro.html)

alvin Kuiper

stop a macro
 
Hi
Is there a way how i can stop a macro
maybe by a commandbutton

reagrds
Alvin




sebastienm

stop a macro
 
Hi Alvin,
Search this newsgroup for: xlerrorhandler
and you'll find your answer
--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"alvin Kuiper" wrote:

Hi
Is there a way how i can stop a macro
maybe by a commandbutton

reagrds
Alvin




AnExpertNovice

stop a macro
 
There are many ways to stop a macro.
on a PC
Ctrl-Break
Ctrl-C
power button (ok some are more drastic than others. ;)

In case you are asking how to allow a user to stop a macro by pressing the
Control key.

(warning, this code was reduced to a "minimal" state and may not actually
since variables may not be declared, orphaned lines might still exist, etc.


Public Const VK_CONTROL = &H11
Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As
Integer

Sub LoopingRoutine()
Dim intResponse As Integer
On Error GoTo ErrorRoutine
Do Until 0 = 1
If GetAsyncKeyState(VK_CONTROL) Then
intResponse = MsgBox(Prompt:="Did you wish to stop looping?",
Buttons:=vbYesNo)
If intResponse = vbYes Then
Exit Do
End If
End If
Loop
ExitRoutine:
Exit Sub
ErrorRoutine:
Resume ExitRoutine
End Sub


--
My handle should tell you enough about me. I am not an MVP, expert, guru,
etc. but I do like to help.


"alvin Kuiper" wrote in message
...
Hi
Is there a way how i can stop a macro
maybe by a commandbutton

reagrds
Alvin






alvin Kuiper

stop a macro
 
Thanks
Alvin


"AnExpertNovice" wrote:

There are many ways to stop a macro.
on a PC
Ctrl-Break
Ctrl-C
power button (ok some are more drastic than others. ;)

In case you are asking how to allow a user to stop a macro by pressing the
Control key.

(warning, this code was reduced to a "minimal" state and may not actually
since variables may not be declared, orphaned lines might still exist, etc.


Public Const VK_CONTROL = &H11
Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As
Integer

Sub LoopingRoutine()
Dim intResponse As Integer
On Error GoTo ErrorRoutine
Do Until 0 = 1
If GetAsyncKeyState(VK_CONTROL) Then
intResponse = MsgBox(Prompt:="Did you wish to stop looping?",
Buttons:=vbYesNo)
If intResponse = vbYes Then
Exit Do
End If
End If
Loop
ExitRoutine:
Exit Sub
ErrorRoutine:
Resume ExitRoutine
End Sub


--
My handle should tell you enough about me. I am not an MVP, expert, guru,
etc. but I do like to help.


"alvin Kuiper" wrote in message
...
Hi
Is there a way how i can stop a macro
maybe by a commandbutton

reagrds
Alvin








All times are GMT +1. The time now is 08:57 AM.

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