Code execution has been interrupted

pujo

Well-known Member
Joined
Feb 19, 2009
Messages
710
Office Version
  1. 2019
  2. 2013
Platform
  1. Windows
Morning all.
I am using a bit of code to scroll through a sheet. It run in a loop and to stop it, I just press escape.
How can I suppress the popup alert "Code execution has been interrupted"?

Application.DisplayAlerts = False does not work...

Here's the vba:
Code:
Sub SlowScroll()
Application.DisplayAlerts = False
On Error Resume Next
    Dim r As Long
    Range("B8").Select
    Do
        DoEvents
        Sleep 2000   'Pause 2 seconds - Scroll speed adjust
        ActiveWindow.SmallScroll Down:=5
        r = r + 1
        If r = 50 Then Range("B8").Select: r = 0
    Loop
    
  On Error GoTo 0
End Sub

Thanks,
PuJo
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Can you specify what you are trying to do as the code you have is in an infinite loop.
 
Upvote 0
You could assign these two macros to two buttons at the top of the sheet. Use freeze panes else they will disappear!

Code:
Dim cancel As Boolean

Sub Stopping()

cancel = True

End Sub

Sub Starting()

Dim r As Long

cancel = False
Range("B8").Select
Do
    If cancel = True Then Exit Sub
    DoEvents
    Application.Wait (Now + TimeValue("0:00:02"))     'Pause 2 seconds - Scroll speed adjust
    ActiveWindow.SmallScroll Down:=5
    r = r + 1
    If r = 50 Then Range("B8").Select
Loop

End Sub
 
Upvote 0
decadence,
I am trying to automate scrolling down a page.

Here is the deal. The worksheet is the stands for a fishing tournament.
At the end of the tournament, I want the page to scroll from top to bottom in an infinite loop as there is a separate monitor for viewers to look at.
The code works as I had it however when I stop the macro by pressing {esc} I get that "Code execution has been interrupted" popup message.
As I will not always be using the spreadsheet, other users will freak out when they see the error message. So if I can just get the message suppressed I would be happy unless there is a better way to it.

Thanks,
PuJo
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top