I am using the 64-bit version of Excel and have an Excel Macro workbook I have created and been using successfully for the last year. Today my workbook started crashing when doing a weekly daily upload that has not previously been an issue (no debug, just crashes and exits completely). I have gone through line-by-line and have found that crash occurs after using the Intersect() method.
This was not a problem when I used the same workbook last week.
I have rewritten a number of these Intersect() instances to use a different functionality to refer back to the same range which has solved the problem I am experiencing today, but I am trying to figure out why the Intersect() method is causing a crash in the first place so I can better design future macros.
Related
Background information -
I have a macro-enabled workbook that interacts with SQL. After some cleaning steps are completed, it eventually runs an elongated list of Stored Procedures and pastes them in an external workbook. It has been working fine up until recently where many of the formulas that reference other tabs in the template are randomly having issues finding the reference...thus changes the formula. I have absolutely no idea how this is occurring.
Formula example:
=IF('16.17.A.SupCarrier'!U9="","",'16.17.A.SupCarrier'!U9)
Formula changes to:
=IF(['16.17.A.SupCarrier']'16.17.A!U9="","",['16.17.A.SupCarrier']'16.17.A!U9)
For what it is worth.....I found a "solution" to the problem. I was previously saving the document while another excel sheet was open which I assume could have been causing memory issues preventing it from saving properly. I saved this document without any other Microsoft apps open and the issue seemed to resolve itself without modifying any formulas.
My employer has recently upgraded from
Excel 2013 (15.0.4805.1001)
MSO (15.0.4919.1002) 32-bit to Excel for Office 365 MSO (16.0.11328.20362) 32-bit
There are no active add-ins (other than referred to below when loaded).
An Excel add-in (xlam) that I have created no longer functions correctly.
The add-in works with an open workbook and formats a lot of 'raw' data as tables (listobjects) and creates a number of PivotTables and Charts in a dashboard-style layout. During the process some blank sheets are copied from the add-in to the open workbook, and renamed as required.
For the most part, everything works fine (pivots created, dashboard created). At the end of the process I create an index sheet by copying a blank sheet from the add-in, and re-naming it (as ...Index). This is where things go wrong. Excel just seemed to 'hang'. On investigation I discovered that the sheet was not being renamed (so further processing stopped).
Delving into this further with error-trapping turned off, if I try to rename the sheet using the immediate window, I get
run-time error 7 Out of Memory
Further, if I manually rename the sheet (Excel interface) and then set the code running from that point, I've discovered that I can't use the CurrentRegion property (some sorting is done on the newly inserted sheet). Any attempt to use CurrentRegion results in
Unable to get the CurrentRegion property of the Range Class
This also applies to using the immediate window on ANY open workbook (e.g. ?Activesheet.range("A1").CurrentRegion.Rows.Count)
These errors persist during the current session of Excel (that is, I can create a blank workbook and try to rename a sheet using VBA but get an error; manually renaming a tab is OK). If I restart Excel everything is fine.
I require to use some global/public variables but (given that everything worked in Excel 2013) can't see that these would be the problem.
Any ideas?
After a further couple of hours looking into this, I established that the error was related in some way to a module which added slicers to the dashboard. The slicers were, in fact added (and stepping through the code no errors were generated).
Adding the slicers in a slightly different fashion appears to have got around the problem, although I am still none the wiser as to why it actually occurred in the first place (the original code for the slicers worked fine in Excel 2013).
I met an issue when I use range.calculate() in VBA.
The following is situation:
32bit Excel 2010 version; Windows 7
50K records as input, being processed one by one;
When running, excel uses ~400M memory;
Links are built in excel tab; the links among cells don't follow from left to right, top to down rule. there are many back and forth links.
call worksheet.range.calculate() in VBA for the calculations in the cells;
Code:
...
Application.Calculation = xlManual
Worksheets("Curve").Range("A1:BO600").Calculate
...
Problem:
Based on Microsoft instruction, Range.Calculate in Excel 2010 resolves the dependencies within the range being calculated. But based on my debugging, Range.calculate() calculates cells from left to right and top to bottom, ignoring all dependencies, just as excel 2000 version. Then the calculation of next record will use the result of the previous one (stored in excel cells now) rather than the refreshed result of its own record since the depended cells may have not been calculated.
It doesn't recur every time when I run my models. I met this issue 2 months ago, after restarted my PC with applying some windows updates automatically, the issue disappeared and Range.Calculate() works as expected in the past 2 months. Now the issue comes back and I could not get rid of it with PC shutdown, or excel closing.
More importantly, if I switch to worksheet.calculcate(), the issue has gone but the running takes more time.
Any clue on this problem? Thanks a lot in advance.
Leal
I am using Excel 2007 (32Bit) on a Windows 7 64Bit machine.
I have a large Workbook with 12 sheets and 18 VBA modules.
All of my subroutines run flawlessly but one is causing the following issue:
The macro itself runs from start to finish successfully just as specified. After running the macro successfully, the workbook crashes, when I try to save it. It also crashes when AutoSave tries to save the workbook. The workbook does not crash when I simply close it.
By crashing, I mean that I get the message "Microsoft Office Excel has stopped working".
In the Windows Event Viewer I have identified the error message 0xc0000005.
In the folder where the workbook is saved, I find the temporary files that Excel creates when saving a workbook (named something like 9BB7B000).
I have tried to repair Excel in the Programs and Features part of the Control Panel but it has not worked. Furthermore no Add-Ins are enabled.
I suspected that the code module of the problem-causing macro was too large (90KB) so I split it up into two modules smaller than 64KB. However, the problem remains.
I would appreciate any help on this issue. I would like to get around reconstructing the workbook manually, if possible, as that would mean an enormous effort.
Thank you very much in advance.
Jochen
I had the same issue some time ago and carried out a research to identify the issue to no avail.
I noticed that it worked fine on workstations with better procs and more ram.
However the only way for me to proceed was to create a new workbook a one-by-one copy each worksheet from the old workbook and see which one is causing the issue. If the macro is causing the error then try to add a "sleep" command between loops so that the Excel file regains control and can execute and awaiting events/commands.
The post was 9 months ago, could you fix it?
What does that specific macro do? Because there are several solutions to this problem.
It seems that a certain "action" in your macro takes too long.
You can search for that specific action and us application.wait to slow your macro down. If this doesn't work, you'll have to find a way to reduce the "workload". But to do that, i'll need to take a look at your code.
Turn off the AutoSave function in Excel Options
I am using a simple macro found in internet for Multiple Goal Sheek in Excel 2010. The link is here
The point is that the macro is working in the example test MultipleGoalSeek(KB19).xls.
given in that link.
But when I try to apply it in my excel sheet, it only solves the first Goal Sheek problem, leaving the others un-calculated. I have no idea why although the macro seems pretty easy (maybe because they are not integers?)
I attach my excel problem with the macro.
Thank you
Hmmm .... this is a very early piece of brettdj code, it dates back to my beginner days a decade or so ago. And it shows .... !
The issue is in the third last row of the code, contrary to the instructons in the file, it was designed to work over columns only (I was running a time-based inventory adjustment at the time)
Change
For i = 1 To TargetVal.Columns.Count
to
For i = 1 To TargetVal.Cells.Count
And it works fine on your sample
I will work on the orginal code to run with variant arrays.