Forum Discussion
Riley_Johnson
Apr 14, 2024Copper Contributor
Measuring Sheet Size Using VBA
Any ideas to improve this code? This macro is intended to calculate the size of each sheet in Excel. In practice, it will trim fat from a template frequently used at work. For instance, a decisio...
- Apr 15, 2024
Riley_Johnson If the workbook is in xlsx or xlsm format, you could look in the zip container to see the size of each sheet's xml file:
Using my editOpenXML example code you could easily extract the xml of any sheet and measure how large it is by taking the Len of the returned (xml) string. See https://jkp-ads.com/articles/excel2007fileformat02.asp
Riley_Johnson
Apr 16, 2024Copper Contributor
JKPieterse Thank you for sharing! This is probably the most technical I've gotten with Excel before. That said, please pardon me if this is a dumb question.
I noticed that once the object was zipped back together, there was no procedure to convert it back to a .xlsx or .xlsm file. So, in effect, is the original .xlsx or .xlsm file destroyed? This is my folder after running the demo procedure in EditOpenXML 004.
JKPieterse
Apr 16, 2024Silver Contributor
I haven't visited that code in ages. But I think when the class instance is properly destroyed at the end of the code, it should automatically clean up after itself.