Exit Loop on keypress? 
Author Message
 Exit Loop on keypress?

Is there a way to exit a loop based on a keystroke by the
user?  For example:

Do
<code>
Loop Until Keypress = ^A

Or is there a way to surpress the message box that comes
up when you break into the code?  Maybe something along
the lines of the On Error statement?

Do
On Break Goto This_line
<code>
Loop

This-line:
<rest of code>

Thanks to all for the help.

Mike



Tue, 24 May 2005 05:30:54 GMT  
 Exit Loop on keypress?
Look at help for

Application.EnableCancelKey

Regards,
Tom Ogilvy


Quote:
> Is there a way to exit a loop based on a keystroke by the
> user?  For example:

> Do
> <code>
> Loop Until Keypress = ^A

> Or is there a way to surpress the message box that comes
> up when you break into the code?  Maybe something along
> the lines of the On Error statement?

> Do
> On Break Goto This_line
> <code>
> Loop

> This-line:
> <rest of code>

> Thanks to all for the help.

> Mike



Tue, 24 May 2005 05:55:33 GMT  
 Exit Loop on keypress?
You can use

  Application.EnableCancelKey

to direct execution to the On Error handler.

--
Jim Rech
Excel MVP



Tue, 24 May 2005 05:57:43 GMT  
 Exit Loop on keypress?
Tom,
Perfect.  Thanks again for the help.

Mike

Quote:
>-----Original Message-----
>Look at help for

>Application.EnableCancelKey

>Regards,
>Tom Ogilvy



>> Is there a way to exit a loop based on a keystroke by
the
>> user?  For example:

>> Do
>> <code>
>> Loop Until Keypress = ^A

>> Or is there a way to surpress the message box that comes
>> up when you break into the code?  Maybe something along
>> the lines of the On Error statement?

>> Do
>> On Break Goto This_line
>> <code>
>> Loop

>> This-line:
>> <rest of code>

>> Thanks to all for the help.

>> Mike

>.



Tue, 24 May 2005 06:11:13 GMT  
 Exit Loop on keypress?
Hi Mikelee,

Quote:
> Is there a way to exit a loop based on a keystroke by the
> user?  For example:

As well as triggering the error handler, you can detect key presses
using Windows API calls, as shown in the checkkey example on my web
site.

Regards

Stephen Bullen
Microsoft MVP - Excel
www.BMSLtd.co.uk



Tue, 24 May 2005 22:06:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. In vbscript exits keypress event.

2. KeyPress or MouseDown to control loop termination

3. Exiting while loops

4. Loop Exit after Last Find

5. Graceful exit from SolverSolve Solver loop found

6. how to exit loop?

7. How to exit if statement and not continue with Do Loop

8. Exiting subs during for each...next loops

9. Can't exit loop

10. Can't Exit Loop


 
Powered by phpBB® Forum Software © phpBB Group