PC Review


Reply
Thread Tools Rate Thread

code breaks in macro

 
 
shanebgross
Guest
Posts: n/a
 
      24th Nov 2009
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 With Quote
 
 
 
 
Rick Rothstein
Guest
Posts: n/a
 
      24th Nov 2009
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" <(E-Mail Removed)> wrote in message
news:CA8FC495-37CF-417F-B5CA-(E-Mail Removed)...
>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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to delet all section breaks bot not page breaks. Smylie Microsoft Access Macros 1 9th Oct 2008 04:04 AM
.NET v2 SP1 breaks some code Jon Davis Microsoft Dot NET Framework 5 8th Aug 2007 06:30 PM
Can I use code/macro to change code/macro in an existing file? =?Utf-8?B?U2NvdHQgQmVkb3dz?= Microsoft Excel Programming 2 14th Feb 2007 05:50 AM
Old macro breaks! davegb Microsoft Excel Programming 4 8th Jul 2005 06:52 PM
JET 4.0 sp7 breaks old vba code! Eric Isaacs Microsoft Access VBA Modules 3 29th Jul 2003 01:16 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:14 PM.