Code execution has been interrupted

Richynero

Board Regular
Joined
Jan 16, 2012
Messages
150
Hi guys,

I am having a problem with some of my code. Codes that worked weeks, months even years ago are now starting to give me problems. I cant seem to work out why.

I keep getting "Code execution has been interrupted" errors. I thought you could only get these errors when you press 'break' or 'esc'?

The code below traces dependants for a block of cells. It worked last time I tried it and now errors at Application.ScreenUpdating = False

I know I could use Application.EnableCancelKey = xlDisabled but I want to get to the root of the cause not just work around it.

Thanks to all in advance.

Richard

Code:
Sub FindDependants()
'############################################
'                                           #
' Written by Richard Nero 7th October 2011  #
'                                           #
'############################################
Dim MyRange As Range
On Error GoTo EndCode
'Choose your area you wish to trace dependants
Set MyRange = Application.InputBox("Select your area you wish to trace dependants:", "Auto Trace Dependant v0.1", Type:=8)
[COLOR=#ff0000]Application.ScreenUpdating = False
[/COLOR]'Cancel the routine if cancel is pressed
   If MyRange Is Nothing = True Then
        'Display message
        MsgBox "The Auto Trace Dependant utility has been canceled", vbInformation
        
        'Exit the routine and close the macro
        Exit Sub
   End If
'Loop through the range
For Each Cell In MyRange
    'Select the cell
    Cell.Select
    
    'Trace dependants
    Selection.ShowDependents
    
    Next Cell
EndCode:
Application.ScreenUpdating = True
End Sub
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Here is a fix that seems to work for me:

better (quicker) solution: just end macro, switch to the VBE and hit Ctrl+Break. After that the code execution doesn't break.
 
Upvote 0
Posting to an old thread, but its answer is still quite useful. I was getting this error every few lines.
I find that post #2 and #3 both work.
I don't understand why the message starts coming up.
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

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