Code Execution has been interrupted

H

Hydra

Still having a problem with this.
As long as I hit the continue button, the code executes perfectly.

It is running a loop with a find statement in it, and then it writes the
data to an array vaiable. That is where it ususally, but not always hands up.

I tried putting in a wait statement so it could catch up, but no luck.

It executes the loop 3,4, 5, 6 times, and then hangs up.

Any more suggestions?
 
H

Hydra

I added a couple of dummy statements after the find statement, that don't
affect the code (move to the next cell and thn move back) and I have the same
problem.

In other words it seems to hang up after the find statement.
 
J

Jim Thomlinson

Based on past experience try shutting XL down and opening it up again. Not
just the spreadsheet but the entire application. That normally fixes it for
me.
 
H

Hydra

the code is huge but I can show part of it. I'e already broken it into
pieces, but maybe I can do more.

No dice on the other. I can reboot the pC and still have the same problem.

-------------------------------------------

Set Myrange = Worksheets("Sheet1").Range("A1: A" & nrows)

'Count the number of summary rows in the sheet and make sure you are
back to the first cell
NumberOfSummaries = Application.WorksheetFunction.CountIf(Myrange,
"SUMMARY:")
'MsgBox ("Number of WBS Elements = " & NumberOfSummaries)
Range("a1").Select


'Redimension the variables to hold all the values needed for the sumaries
ReDim WBSNOS(NumberOfSummaries) 'Variable to hold WBS Numbers
ReDim WBSROW(NumberOfSummaries) ' VAriable to hold the Row Number for
the Summaries
ReDim Addr(NumberOfSummaries) ' Variable to hold the Address for the row
with data needed.


'-------------------Fill the Data arrays for Cost locations

'Run this loop once for each WBS Item Searching for the word "Summary"
'Summary Rows contain the WBS Number
For Counter = 1 To NumberOfSummaries

Cells.Find(What:="SUMMARY:", After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate

' First find the Summary Row and record the WBS number
' And the Row Number for the Summary Row
WBSNOS(Counter) = ActiveCell.Offset(0, 1).Value
WBSROW(Counter) = ActiveCell.Row

'Then find the Next row that contains the words "Total Price"
Cells.Find(What:="Price", After:=ActiveCell, LookIn:= _
xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False).Activate



'Record the Address for the Total Price Row
ActiveCell.Offset(0, 1).Select
ActiveCell.Offset(0, -1).Select
Addr(Counter) = ActiveCell.Address


--------------------------------------------------------------------------------


This last line is where it usuallly hangs up. Then hit the continue button
and off you - for another four or five loops.


"Sheet 1" is around 4000 lines and 72 columns.
 
J

Just Another Yahoo!

I'm not sure about what's going on but put this at the beginning of your
code:
Application.EnableCancelKey = xlDisabled
 
H

Hydra

Here is a new twist.

Running a different macro against another file, I'm now getting the same
disruption, where I never have before.
 
H

Hydra

Magic.

That worked perfectly, Thank You.

Now what I'd like to know, is how does one ever learn such a thing, and even
if you knew it existed, how would you look it up after you forgot the command
name?
 
J

Just Another Yahoo!

Very good question!

At a contract job I had the same issue as you, seemingly random code
breaking for no reason. Typically it required me to reboot my machine.
Just lived with it. Now at my current (full-time...yeay!) job I was
scanning the code of my predecessor and noticed that clause. I asked him
what it was all about. Apparently he was having the same issue of odd
program breaks and this was the solution he found after some searching.

I'm not an Excel MVP so if one of them will chime in it would be appreciated
(hint hint). What I know from it is, it disables the Escape key (Esc). Why
this works I do not know, particularly when you and I both know that we
never even hit the Esc key and it is virtually impossible that we even could
consistently hit the same line of code!

Everyone, please use the Help functionality of the VBE editor to find out
what this command does. Basically, it allows the Esc key to be disabled.
The bad thing is, you can't use the Esc key to STOP the execution of the
code! Yikes! The good thing is, you don't have to re-enable it at the end
of your code because Excel will default to turning the Esc key back on
(whew!).

As to remembering it, well, documentation. I keep a folder with me at work
or (when I was contracting) on a jump drive of useful code snippets and
tips/tricks. Use a descriptive file name since 8 character file names are
soooo Win95 ago! I also have a list of MVP web sites that I search as well
since they have good, exact, and working code that is normally well
documented ;-)

I'm glad I was finally able to help someone. Too bad this couldn't be made
a "sticky" like what's done in forums.
 
S

Stathi Anagnostatos

Hi Guys

I have had the same problem for the last 2 days.
This is simply what I found.
I had an add-in from INet.
IConnect added to my sheet.
Every time the add-in updated a price on the sheet te code would give the above error.
I deleted the link from edit links and what do you know. No more error.

Hope this helps.

Thanks




Hydra wrote:

Code Execution has been interrupted
25-Sep-09

Still having a problem with this
As long as I hit the continue button, the code executes perfectly

It is running a loop with a find statement in it, and then it writes th
data to an array vaiable. That is where it ususally, but not always hands up

I tried putting in a wait statement so it could catch up, but no luck

It executes the loop 3,4, 5, 6 times, and then hangs up

Any more suggestions?

Previous Posts In This Thread:

EggHeadCafe - Software Developer Portal of Choice
Transfer Session State From Classic ASP to ASP.NET
http://www.eggheadcafe.com/tutorial...2-436a9db5c402/transfer-session-state-fr.aspx
 
J

JLGWhiz

Thanks for the info. I have seen other postings where certain virus
protection can cause similar problems.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top