Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default code breaks in macro

I have a very simple macro below which cuts and pastes contents of one cell,
then deletes a few columns. When running the macro I get the "Code execution
has been interrupted" error. I can simply hit continue and the macro
completes fine. Sometimes it goes all the way through. When it does break,
it's not always at the same point. The macro was recorded using the "Record
New Macro" menu functions and hasn't been altered. Any ideas why this might
happen?

Sub Macro1()
Range("Q8").Select
Selection.Cut
Range("R8").Select
ActiveSheet.Paste
Columns("A:A").Select
Selection.Delete Shift:=xlToLeft
Columns("E:E").Select
Selection.Delete Shift:=xlToLeft
Columns("F:F").Select
Selection.Delete Shift:=xlToLeft
Columns("G:G").Select
Selection.Delete Shift:=xlToLeft
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default code breaks in macro

I have not seen a definitive answer to this problem in the past. Rebooting
the computer, perhaps several times, clears the problem most of the time,
but not always; otherwise you can try shutting the computer off for
**several** minutes before turning it back to see if that resolves the
problem. Worse come to worst, you can put this line of code at the beginning
of your code...

Application.EnableCancelKey = xlDisabled

This seems to stop the problem... effectively, it shuts the Esc key off...
but it might make it impossible to stop your program without using
Ctrl+Alt+Delete to stop your entire Excel session, so remember to back up
your workbook frequently if you plan to use it. Sorry I don't have a better
answer for you.

--
Rick (MVP - Excel)


"shanebgross" wrote in message
...
I have a very simple macro below which cuts and pastes contents of one
cell,
then deletes a few columns. When running the macro I get the "Code
execution
has been interrupted" error. I can simply hit continue and the macro
completes fine. Sometimes it goes all the way through. When it does
break,
it's not always at the same point. The macro was recorded using the
"Record
New Macro" menu functions and hasn't been altered. Any ideas why this
might
happen?

Sub Macro1()
Range("Q8").Select
Selection.Cut
Range("R8").Select
ActiveSheet.Paste
Columns("A:A").Select
Selection.Delete Shift:=xlToLeft
Columns("E:E").Select
Selection.Delete Shift:=xlToLeft
Columns("F:F").Select
Selection.Delete Shift:=xlToLeft
Columns("G:G").Select
Selection.Delete Shift:=xlToLeft
End Sub


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
Sharing a workbook breaks VBA code? Jason Excel Programming 5 January 9th 06 07:52 AM
Module to set Page Breaks based on criteria through code DoctorV[_4_] Excel Programming 0 July 20th 04 06:32 PM
Locked workstation breaks code? Scott Stonehouse Excel Programming 0 June 8th 04 06:22 PM


All times are GMT +1. The time now is 10:59 PM.

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

About Us

"It's about Microsoft Excel"