File size increase from .xls to .xlsm

LeggoMyEggo

New Member
Joined
Feb 15, 2011
Messages
25
Hello all,

I have been encountering an error when working with my workbook in the new .xlsm format. When initially saved, it takes up about 20 mb of space. However, one of the next times I save it (having changed little except to run a macro that causes no similar problems as a .xls) the file is >200 mb in size.

I am able to fix this by saving it as a .xls under a different name and then reopening and resaving with a .xlsm extension, but this is happening too frequently to be practical (and the file will be a scheduled task, so this file size increase will become a problem...)

Are there any known glitches that cause this large increase in file size...?

My workbook has multiple Active-X controls, some non-activeX controls, an advanced filter, and about 28 automatically generated charts (with a 3-d effect and a border).

Thank you,
Alex
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
I can't do that, the charts are the purpose of the file.

In a .xls the file size is 50 mb, when I initially save it as a .xlsm it is 20, however it is somehow corrupted to take up >200mb if I save it as a .xlsm multiple times.


What is the cause of the corruption? Or at least, what are some common causes...?

Thanks,
Alex
 
Upvote 0
I have continued to look into this, and when running a compatability check to save back to .xls, it states that in most of my worksheets, I am using more than the ~65000 row limit. I am not intending to, and I think this is the problem.

What are some ways that I could be unintentionally increasing the number of rows used in my worksheet, or how could I reduce them with vba to keep the file size from ballooning...?

I didn't have this problem in .xls, so what could have changed...?


Thank you,
Alex
 
Upvote 0
Do you have any event-handling code in the workbook? It could be that somewhere there is code that is changing cells in all rows in a sheet?
 
Upvote 0
I have just found the offending line of code...
The number of lines that I can scroll to jumps from ~60,000 to the 1 million max after this line:

Code:
    Worksheets("OtherWkSht").Range("J:J").SpecialCells(xlCellTypeVisible).Copy Worksheets(WkshtName).Range("A1:A1000")

With this, I am copying the results of an advanced filter. It is the destination worksheet that is growing in size. I orgininally had simply:

Code:
  Worksheets("OtherWkSht").Range("J:J").Copy Worksheets(WkshtName).Range("A:A")
(which had the same problem. the first code was just my attempt to fix it)

How can I execute the transfer of the filtered rows of data without creating so many extraneous lines on the destination worksheet...?

Thanks,
Alex
 
Upvote 0
Assuming no data below the range of interest:
Code:
Dim rngData as range
with Worksheets("OtherWkSht")
    set rngdata = .Range("J1", .cells(.rows.count, "J").End(xlup))
End With
rngdata.SpecialCells(xlCellTypeVisible).Copy Destination:=Worksheets(WkshtName).Range("A1")
 
Upvote 0
Fixed it!


I had previously found the lastrow of the source data worksheet, so I used that in conjunction with the SpecialCells property and it works well!

Code:
With Worksheets("HistoricalData")

    LastRow = .Cells(Rows.count, "A").End(xlUp).Row
    .Range(Cells(1, 10), Cells(LastRow, 10)).SpecialCells(xlCellTypeVisible).Copy Worksheets(WkshtName).Range("A1") 

End with

This fixes my file size issue as well!

Thank you,
Alex
 
Upvote 0
You need periods before both your Cells calls to qualify them with the worksheet.
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,740
Members
452,940
Latest member
Lawrenceiow

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top