Written by Allen Wyatt (last updated September 17, 2022)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021
Chris has a very large (350 GB) workbook. There are many times, when opening the workbook, that the macros it should contain are stripped out and the workbook is deemed corrupt. In those cases, Chris has to rely on the frequent backups he makes. He wonders how he can stop this from happening.
When I read the question from Chris, my immediate reaction was to question the size of the workbook file. It seems very doubtful that a workbook is actually 350 GB, as limits on both Access and SQL Server files is in the 2 GB neighborhood. This caused me to go look up the limits published by Microsoft:
https://support.microsoft.com/en-us/office/excel-specifications-and-limits-1672b34d-7043-467e-8e27-269d656771c3
The page indicates that there are limits similar to Access and SQL Server when running the 32-bit version of Excel. If using the 64-bit version, however, the official word is that you are limited only by "available memory and system resources." So, theoretically, a 350 GB file could be opened.
The germane question, however, is should you open such a workbook, even if you could. Feelings among ExcelTips subscribers are mixed on the answer, with most leaning toward an emphatic "no way!" Most long-time Excel users understand that the larger the workbook file, the more susceptible the file is to problems and corruption.
This tendency would explain Chris' experience with the macros getting stripped off and the workbook showing as being corrupt. It should be noted, as well, that it isn't the macros getting stripped off that corrupts the workbook, but the workbook becoming corrupted that causes the macros to get stripped off—Excel, in the process of trying to recover a workbook it considers corrupt, will routinely strip off the macros.
There is a two-fold solution to this problem. First, open a non-corrupt copy of the workbook and transfer the macro modules to a different, blank, macro-enabled workbook. You can then save the workbook as an add-in, which you can then load back into Excel. In that way, even if your very large workbook becomes corrupted (again), you still have your macros available through your add-in.
The second thing to do is to find ways to make your workbook smaller. This will obviously take some rethinking of how you store your data and what is contained in your workbook. Perhaps, for instance, you could have one workbook for each year of data, for each project, or for each department. How you divvy up the data will obviously depend on the nature of your data, and it will take some work. If you combine this with the previous suggestion to make your macros into an add-in, then your macros will be available in all of your smaller, more manageable, and less corruptible workbooks.
It is worth revisiting my original speculation—is Chris's workbook really 350 GB, or was that a type and the workbook is a much smaller 350 MB? If the smaller workbook is really what Chris is working with, then the same suggestions remain—spin your macros off to an add-in and divide your workbook data into a series of smaller workbooks.
Regardless of the workbook size—350 GB or 350 MB—when dividing up the data into separate workbooks, don't do so by copying the original workbook and trimming it back. If the workbook is corrupted in some way, you'll want to reconstruct the workbook from scratch, copying formulas and values, as necessary, from the problem worksheet. Don't copy entire worksheets, however, to the new workbooks, as that may end up copying the corruption you want to remove.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (12983) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021.
Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!
Tracking down memory errors in a macro can be frustrating. The error message is inherently vague and correcting any ...
Discover MoreWhen sharing workbooks with others, you may find that the macros in those workbooks may not work as you expect. This tip ...
Discover MoreMacros are often used to process information in a workbook. If your macro makes changes in what is selected in the ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2022-09-20 09:58:22
J. Woolley
@Christian S.
If you open your datafile and press Alt+F11 to open VBE, you can edit and test your add-in's VBA as you suggested. Just make sure you press Ctrl+S while the add-in is active in the VBE's window. This will save the changes to your add-in file. If you press Ctrl+S while Excel's window is active, changes to your add-in will not be saved.
You might want to backup your add-in file before making changes, just in case.
See https://sites.google.com/view/MyExcelToolbox/
2022-09-19 04:23:45
Christian S.
I faced similar problems (actually at that time my file was about 700 MB) and I changed it as proposed into one AddIn and one datafile (.xlsx). The advantage: even (maybe twice or three times per year instead of ~once per week) most of the time both files remain usable.
The disadvantage: my macros are living code and need updates and extensions every now and then. Normally I did these updates step by step with my data. Well, changes in the AddIn are lost as soon as you close Excel. You need to remember to save the code e.g. to Notebook before closing and then you can copy the code to the 'master'-file of your AddIn.
Soon you may add personal tabs in the Ribbon. If you are not using the latest version of Excel - which, as I read allow adding a tab on the fly - you may find useful information in https://www.rondebruin.nl/win/s2/win001.htm
2022-09-17 06:00:00
Andrija Vrcan
There is one more solution: Separate the workbook with the data and the workbook with the VBA code, and manage the data via Toolbar or Ribbon.
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments