Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Hot key to stop a LOOP


Is there away to stop a loop using a hot key, <esc or the <ctrl-break
key?

Any help would be appreciaited

--
joopdo
-----------------------------------------------------------------------
joopdog's Profile: http://www.excelforum.com/member.php...fo&userid=3133
View this thread: http://www.excelforum.com/showthread.php?threadid=51059

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default Hot key to stop a LOOP

Yep, use Ctrl-Break.

Sometimes you might have to press it a time-or-two to get the key-press to
register. It will give you the options to continue,end, debug, help.

--
Regards,
John


"joopdog" wrote:


Is there away to stop a loop using a hot key, <esc or the <ctrl-break
key?

Any help would be appreciaited.


--
joopdog
------------------------------------------------------------------------
joopdog's Profile: http://www.excelforum.com/member.php...o&userid=31336
View this thread: http://www.excelforum.com/showthread...hreadid=510599


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 486
Default Hot key to stop a LOOP

Here is the link... Sorry posted before I pasted... :-)

http://msdn.microsoft.com/library/de...HV03076682.asp
--
HTH...

Jim Thomlinson


"joopdog" wrote:


Is there away to stop a loop using a hot key, <esc or the <ctrl-break
key?

Any help would be appreciaited.


--
joopdog
------------------------------------------------------------------------
joopdog's Profile: http://www.excelforum.com/member.php...o&userid=31336
View this thread: http://www.excelforum.com/showthread...hreadid=510599


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 486
Default Hot key to stop a LOOP

Give this a look... It catches the escape key.
--
HTH...

Jim Thomlinson


"joopdog" wrote:


Is there away to stop a loop using a hot key, <esc or the <ctrl-break
key?

Any help would be appreciaited.


--
joopdog
------------------------------------------------------------------------
joopdog's Profile: http://www.excelforum.com/member.php...o&userid=31336
View this thread: http://www.excelforum.com/showthread...hreadid=510599


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 486
Default Hot key to stop a LOOP

Here is some quick code based on that link... Toss it into a command button
and give it a try. It resets the application settings you may have changed,
and also give you the option to resume the loop...

Private Sub CommandButton1_Click()
Dim lng As Long
On Error GoTo ErrorHandler
Application.EnableCancelKey = xlErrorHandler
For lng = 1 To 1000000

Next lng
Exit Sub
ErrorHandler:
If Err = 18 Then
If MsgBox("Do you want to stop?", vbYesNo, "Quit?") = vbYes Then
Application.StatusBar = False
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
End
Else
Resume
End If
End If
End Sub
--
HTH...

Jim Thomlinson


"Jim Thomlinson" wrote:

Here is the link... Sorry posted before I pasted... :-)

http://msdn.microsoft.com/library/de...HV03076682.asp
--
HTH...

Jim Thomlinson


"joopdog" wrote:


Is there away to stop a loop using a hot key, <esc or the <ctrl-break
key?

Any help would be appreciaited.


--
joopdog
------------------------------------------------------------------------
joopdog's Profile: http://www.excelforum.com/member.php...o&userid=31336
View this thread: http://www.excelforum.com/showthread...hreadid=510599




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Hot key to stop a LOOP


Great Stuff.


Code:
--------------------
Sub CommandButton1()
Dim lng As Long
On Error GoTo ErrorHandler
Application.EnableCancelKey = xlErrorHandler
MsgBox "This may take a long time: press ESC to cancel"
For lng = 1 To 1000000
' do something here
Next lng
Exit Sub
ErrorHandler:
If Err = 18 Then
If MsgBox("Do you want to stop?", vbYesNo, "Quit?") = vbYes Then
Application.StatusBar = True 'false
Application.EnableEvents = True
Application.Calculation = xlCalculationAutomatic
MsgBox "macro stopped"
End
Else
Resume
End If
End If
--------------------


This is great and it works!

Again Thanks


--
joopdog
------------------------------------------------------------------------
joopdog's Profile: http://www.excelforum.com/member.php...o&userid=31336
View this thread: http://www.excelforum.com/showthread...hreadid=510599

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to stop program in a big loop? miao jie Excel Programming 1 December 13th 04 12:32 PM
how to stop a loop L775 Excel Programming 6 November 29th 04 08:37 PM
HELP!!!! Can't stop a loop (NOT an infinite loop) TBA[_2_] Excel Programming 3 December 14th 03 03:33 PM
Stop a loop with a keyboard Fernando Ortiz Excel Programming 1 November 22nd 03 03:39 AM
newbie: stop a FOR NEXT loop Mike H[_7_] Excel Programming 4 October 11th 03 04:47 PM


All times are GMT +1. The time now is 10:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"