Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Reducing File Size.

Reducing File Size

by Allen Wyatt
(last updated December 4, 2019)


James complained about an oddity that he noted with his workbooks. He has a workbook to which he added some macros, and doing so increased the size of the file used to store the workbook. (This makes sense—the macros are stored with the workbook.) When James later deleted the macros, Excel did not shrink the size of the workbook file back to its original size.

This behavior is viewed by some as poor design in Excel—the macro data is removed, but the file size remains bloated. There are a couple of things you can try to again regain your svelte file size.

First, try using Save As instead of Save. Doing so causes Excel to create a brand new file for your workbook, and in the process, free up some space. If that doesn't work, you should try individually copying your worksheets to a brand new workbook, and then saving the new workbook. If doing that doesn't work, then you can try copying just the worksheet data (not the actual worksheets) to a different workbook. Obviously, this can become quite time-intensive.

Another thing to try, provided you still have some macros in the workbook, is a free utility called CodeCleaner, written by Excel MVP Rob Bovey. You can find the program on this page:

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2507) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Reducing File Size.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...


Size Limit for Documents

Word can handle large documents, but how large is large? This tip examines the issue and provides some advice on how ...

Discover More

Selecting a Paper Source

When you print a worksheet, you may want to specify that the printout be done on a particular paper tray in a particular ...

Discover More

Formatting Canadian Postal Codes

Postal codes in Canada consist of six characters, separated into two groups. This tip explains the format and then shows ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More ExcelTips (menu)

Importing Multiple Files to a Single Workbook

If you use Excel to work with data exported from another program, you might be interested in a way to import a large ...

Discover More

Closing Multiple Files

When working with multiple workbooks open, you may want a way to close them all with a single command. Here's the secret.

Discover More

Pulling Filenames into a Worksheet

You can use Excel for all types of data processing. You may want to work with filenames in a worksheet, but the first ...

Discover More

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.


If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is four less than 8?

2016-11-06 19:21:08

Dave Unger

I'd be interested in any comments about Ribbon Commander VBA cleaner vs Rob Bovey's CodeCleaner. Is one better than the other?

2015-11-07 03:21:16


my excel file size is 25.4 MB (26,697,811 bytes) i can't open please kindly suggest me how to open my excel file

2015-05-31 04:12:30


The easiest way to remove all VBA code from a macro-enabled Office file is to save the file in a macro-free format. For example, save a .xlsb workbook as .xlsx

However you should not open any workbook that you suspect that it has malicious macros or code with bugs that may damage your data or PC. If you disable macros, then you are left with no choice other than to delete macros manually or open and save each file in a macro-free format.

However, the Macro Mover add-in allows you to mitigate security risks and work more productively:

Macros are removed from closed files only! There is no need to disable all macros from the Trust center. Your files will not be opened in Excel, so VBA code cannot be executed.

Code is deleted from closed files, so you don't have to wait while opening/saving large files.

VBA code can be removed from any macro-enabled Office file (including add-ins), even from locked VBA projects.

Macros can be removed without changing the extension of the file. You can still take advantage of the high compression ratio offered by binary files (.xlsb), while erasing macros fast

Read more:

2015-05-31 04:09:11


Ribbon Commander offers the CleanVBAProject method, which can remove all code garbage from any macro-enabled or binary workbook and Add-ins instantly.

The Ribbon Commander VBA cleaner removes all redundant caches from closed files, so VBE doesn't get a chance to replace the information.

Cleaned files are smaller in size. Nowadays files are moved between desktops and the cloud more frequently than ever before. On an enterprise level, smaller files translate into decreased costs for online storage and bandwidth. Backups and downloads can be executed faster. Email bouncebacks could be stopped and email storage requirements could be reduced.

For years the 'golden' standard for Excel VBA code cleaning has been module export - import.
Ribbon Commander aims to raise the bar by offering several productivity advantages for VBA developers.

Reclaim existing storage space on desktop PCs and servers by replacing large macro-enabled Microsoft Office files with smaller versions. Slow storage growth as new files are added.

Read more:

2015-04-14 21:20:09

David Ruben

Thank you David Baker - previously I would try manually selecting the column beyond my last entry, Shift+Ctrl+Right-arrow to select all rows to right and then right-click delete; and then similarly for rows.

Of course nothing bloats a workbook more that setting it up as a shared workbook that can be opened and edited by different users at the same time. Even if one limits the number of days that the change history is kept for, the file size seems inevitably to expand. The solution I use is somewhat clumsy, but I work out the file size when empty of data (but with headers, formating, any lookup tables for validation rules, macro code etc) and then how it increases with additional rows of data. This allows a macro to then calculate what the approximate size of the file should be for the given number of rows of records it has. A macro then automatically:
a) checks if the actual file size exceeds a preset multiple of the calculated presumed size (e.g. x3)
b) checks if the number of active users is just 1
c) then will offer to unshared the workbook (which causes the file to be saved), and then resaved again as a shared workbook.
This inelegantly but effectively clears the history and the bloating for shared files.

2015-04-05 17:35:41

David Baker

Hi Allen

Thank you for your useful Excel and Word tips - great work.

Excel file bloat is problem that I have seen a number of times over the years even in workbooks without macros. There is an excellent piece of code that I have used successfully over the years, ExcelDiet.

The results have been outstanding in some situations when Excel gets confused about the actual range used by the workbook.

Cheers David

This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.

Newest Tips

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.