M
myemail.an
I - unfortunately - use Excel 2007. I wrote a macro for the following
task:
- a folder contains a number of files, each with 3 tabs, "Source
Data", "Details" and "Summary". These files are reports, all in the
same format as they are created by
another macro. "Details" and "Summary" contain formulas based on the
content of "Source Data"
- the macro cycles through all files in the folder and merges them in
2 files, pasting values only and leaving out the source data
- the output is therefore 2 files: "MergedDetails" and
"MergedSummaries"; each of those files contains one tab per original
source file. For example, if you want to quickly compare the details
of File1 and File2, you'll open MergedDetails and compare the tabs
File1 and File2. Same for the summaries.
The problem is, my code kept crashing Excel. To isolate the problem, I
separated the code into 2 different macros: one for the details and
one for the summary.
The latter works, the former keeps crashing Excel.
I tried all sorts of workarounds: I ran the macro on local (rather
than network) folders, I set 2 to 4 second delays before closing and
saving files, but nothing changed.
The weirdest thing is that, debugging the code, I noticed that Excel
always crashed at different points in the macro: sometimes after
processing the 3rd file, some other time after processing the 8th,
sometimes after closing one file, some other time after copying some
cells... I never got any out of memory error.
I don't get this. If my code is wrong, why does Excel always crash at
different points in the code?
Finally, I tried the very same code on a different PC running Excel
2003 (and on the very same source files), and it does work fine!
Would you have any suggestions on how I can get my code to run with
Excel 2007? Or at least on how I can get some additional help?
I know some Excel 2007 macro functionalities are no longer supported (
like Application.Filesearch, for instance), but at least in those
cases you get a clear error message that helps you understand what the
issue is!
task:
- a folder contains a number of files, each with 3 tabs, "Source
Data", "Details" and "Summary". These files are reports, all in the
same format as they are created by
another macro. "Details" and "Summary" contain formulas based on the
content of "Source Data"
- the macro cycles through all files in the folder and merges them in
2 files, pasting values only and leaving out the source data
- the output is therefore 2 files: "MergedDetails" and
"MergedSummaries"; each of those files contains one tab per original
source file. For example, if you want to quickly compare the details
of File1 and File2, you'll open MergedDetails and compare the tabs
File1 and File2. Same for the summaries.
The problem is, my code kept crashing Excel. To isolate the problem, I
separated the code into 2 different macros: one for the details and
one for the summary.
The latter works, the former keeps crashing Excel.
I tried all sorts of workarounds: I ran the macro on local (rather
than network) folders, I set 2 to 4 second delays before closing and
saving files, but nothing changed.
The weirdest thing is that, debugging the code, I noticed that Excel
always crashed at different points in the macro: sometimes after
processing the 3rd file, some other time after processing the 8th,
sometimes after closing one file, some other time after copying some
cells... I never got any out of memory error.
I don't get this. If my code is wrong, why does Excel always crash at
different points in the code?
Finally, I tried the very same code on a different PC running Excel
2003 (and on the very same source files), and it does work fine!
Would you have any suggestions on how I can get my code to run with
Excel 2007? Or at least on how I can get some additional help?
I know some Excel 2007 macro functionalities are no longer supported (
like Application.Filesearch, for instance), but at least in those
cases you get a clear error message that helps you understand what the
issue is!