Execution ends without error message in middle of program

G

Guest

I have several macros that I can not debug. When I run them in the debugger
they go along just fine and then act as if they they just encountered an END
statement. That is execution ends without any error message or other
indication of failure. The code lines do not seem to have any errors. For
example:
Selection.EntireRow.Hidden = True
I get a valid selection in the immediate window ( ? selection.address -->
$1:$100) just before executing this line but the macro just stops. Once when
I tried to add an On Error Goto x I got a can not enter break mode here
message. Now execution just terminates.

Any ideas/tips
 
G

Guest

Nothing obvious in the single line of code and your description. Do you have
user defined functions in the worksheet - if so, these can often be
problematic if not populated with good error handling code.
 
G

Guest

Some background:

Running on Windows 2000
Running Excel 2000 (9.0.8950 SP-2)
The company I am working for (Shell) as a contractor "locks" their PC's
preventing writing to most areas of the hard disk and registry. As I am
considered a "developer" I have both a locked and an unlocked PC. Unlocked PC
have access to most of the hard disk but apparently still lock some things.
Problem is the same on both. Therefore consider the possibility of a
rights/permissions problem.

I write most of my code by using the macro recorder and then editing it to
make it generic (example: I change the "hard" coding of file names to code
tyhat will handle any file name. same for ranges etc..)

I have some user defined function and subroutines but am not using them in
the lines of code that are crashing.

Particulars of problem:
Code seems to run to completion but does not do all that it should.
Then I trace it using the debugger code runs fine until it gets to problem
line and then just terminates as if it encountered an END statement. That is
there is no error message.

Code with problem is in a sub that is called by another sub. I read that ON
ERROR GOTO 0 does not always turn generic error checking back on ( the error
routines of calling procedures are still in effect?). To try to test for this
I added ON ERROR GOTO X: just before the problem line and at the bottom of
the same sub added X: and a msg. This was not triggered. The code continued
to end without warning and for no apparent reason.

On occasion (rarely) I have had this problem with other lines of code so it
may not be the line at all although when it does occur it is consistant i.e.
the same line continues to cause the problem and when commented out the
problem goes away.

My workaround has been to comment out or delete the code and code around the
issue it need be.
 
N

NickHK

I tend to avoid using Selection, as by itself you have no idea what it
evaluates to.

Maybe add:
Dim DelRange as range

set delrange=selection

Also, you can play with settings on :
Tools>Options>General>Error Trapping

NickHK
 

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