Excel crashes when copying worksheets

  • Thread starter Martien Janssen
  • Start date
M

Martien Janssen

Dear all,

I have created a workbook and an excel add in file. With the workbook open I
use a procedure from the add-in which creates copies of a worksheet. It
works with something like:
Worksheets("Template").Copy Before:=Sheets("WorkArea")
Worksheets("Template (2)").Visible = True
Worksheets("Template (2)").Activate
ActiveSheet.Name = "T" & HNumber
Then a routine is called which fills the new worksheet with data coming from
text files.
Call LoadData(FileName, ErrorCode)
This is then repeated in a loop.

This procedure works only 80 % of the time well. Every now and then Excel
(97 version) crashes and reports: the instruction at "0x...." referenced
memory at "0x...". The memory can not be "read". This happens very
irregularly and it happens either in the procedure part where the worksheet
is copied as well as in the procedure which loads the data . If I try to run
the whole procedure using the debugger the crash may not happen at all or at
a completely different point then before. I have tried many things to
improve the stability but none with real success. Can someone give any
guidelines how to improve the calculation stability ? Probably I have to
mention that the worksheets make a number of calls to functions contained in
the add-in. I have already tried to make these functions as save as
possible.

Thanks, any suggestions are appreciated

Martien
 

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