Advertisement

12.09.2004 at 06:56AM PST, ID: 21236404
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Large Excel file - how to reduce the size?
Tags: excel, file, size, reduce, large
I have an Excel file with UsedRange = A1:CH102. The saved size is 4151 kB. I have found a way to reduce the size:

Option Base 1

Sub ReduceSize()
  Dim lAntR As Long
  Dim iAntK As Integer
  Dim aR() As Single
  Dim aK() As Single
  Dim n As Integer
  Dim sFil1 As String
  Dim sFil2 As String
  Dim sKat As String
  Dim sArk As String
 
  sFil1 = ActiveWorkbook.Name
  sKat = ActiveWorkbook.Path
  sArk = ActiveSheet.Name
 
  lAntR = Cells.Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
  iAntK = Cells.Find(What:="*", SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
 
  ReDim aR(lAntR)
  ReDim aK(iAntK)
  For n = 1 To lAntR
    aR(n) = Rows(n).RowHeight
  Next n
  For n = 1 To iAntK
    aK(n) = Columns(n).ColumnWidth
  Next n
 
  Application.CutCopyMode = False
  Range(Cells(1, 1), Cells(lAntR, iAntK)).Copy
  Workbooks.Add
  sFil2 = ActiveWorkbook.Name
  ActiveSheet.Name = sArk
  ActiveSheet.Paste
  Application.CutCopyMode = False
 
  For n = 1 To lAntR
    Rows(n).RowHeight = aR(n)
  Next n
  For n = 1 To iAntK
    Columns(n).ColumnWidth = aK(n)
  Next n
 
  Workbooks(sFil1).Close savechanges:=False
  Application.DisplayAlerts = False
  Workbooks(sFil2).SaveAs sKat & "\" & sFil1
  Application.DisplayAlerts = True
End Sub

But still the size is about 1400 kB.
Do anybody know what was occupying space outside the UsedRange?
Do anybody know what kind of format or content or anything else which takes much space? Is there a way to analyse the size of each cell or element in the sheet?

Start your free trial to view this solution
Question Stats
Zone: Software
Question Asked By: smeden
Solution Provided By: XL-Dennis
Participating Experts: 7
Solution Grade: B
Views: 938
Translate:
Loading Advertisement...
12.09.2004 at 07:01AM PST, ID: 12783819

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.09.2004 at 07:21AM PST, ID: 12784074

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.09.2004 at 07:32AM PST, ID: 12784193

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.09.2004 at 07:38AM PST, ID: 12784250

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.09.2004 at 10:27AM PST, ID: 12786018

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.09.2004 at 10:30AM PST, ID: 12786033

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.09.2004 at 11:20AM PST, ID: 12786464

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.10.2004 at 12:21AM PST, ID: 12790524

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.10.2004 at 03:31AM PST, ID: 12791280

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.10.2004 at 04:23AM PST, ID: 12791531

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
12.10.2004 at 07:30AM PST, ID: 12793053

Rank: Guru

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.20.2005 at 07:38AM PDT, ID: 13824882

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.20.2005 at 07:53AM PDT, ID: 13825129

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.20.2005 at 08:16AM PDT, ID: 13825463

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.16.2005 at 07:14AM PDT, ID: 14010508

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.16.2005 at 07:36AM PDT, ID: 14010689

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
05.16.2005 at 09:34PM PDT, ID: 14016090

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
12.09.2004 at 07:01AM PST, ID: 12783819

Rank: Genius

Hi smeden,

What is in those cells. Are there many formula? If so then it -could- be that. If there are no formula and the cells just contain data, then how much data is there. The following sub will tell you the total length of all the text in your sheet. Then you need to think about the formatting and pictures etc. does it come close?

Sub CountAllText()
Dim Cel As Range
Dim ws As Worksheet
Dim result As Integer
For Each ws In ActiveWorkbook.Worksheets
For Each Cel In ws.UsedRange
result = result + Len(Cel.Formula)
Next
Next
msgbox result
End Sub

Cheers,
MalicUK.
 
12.09.2004 at 07:21AM PST, ID: 12784074
Hi MalicUK

There are many formulas in my sheet, so maybe I cannot reduce the size more than that. But I often find that the UsedRange reaches farther down and to the right than the range that really has content. Then it is no help to delete the actual columns or rows. The only way I have found to get a cleaner sheet is to copy the content to a new sheet, as I showed in the code. But it is a risk to lose some information, e.g. my code loses the print area.
 
12.09.2004 at 07:32AM PST, ID: 12784193

Rank: Genius

smeden,

You don't need to use that to copy it to a new sheet. It is a well known bug in Excel - when you delete data is doesn't change the page dimensions and remember the cells are empty. All you have to do is highlight the first empty column and hold down Shift+Ctrl and press the right arrow. Now goto Edit->Delete. Now highlight the first empty row, hold down Ctrl+Shift and press the down arrow. Now Edit->Delete again. Now press Ctrl+Home. Now save your workbook. This should clear the sheets, and you wil have kept your print area.

And have you run that sub - what did the message box give as the total char length. You can add (a wild ass guess) 25% onto that for formatting and hopefully you should be near the file size.
Assisted Solution
 
12.09.2004 at 07:38AM PST, ID: 12784250

Rank: Master

Smeden,

This is a known issue, especially with Excel 97.

Does this happen when you have deleted some data off of a sheet (i.e. performed a "delete" command)?

It has been my experience that Excel doesn't know how to "release" its disk allocation when data has been deleted.

When you copy and paste to a new workbook, Excel tells the OS to start a fresh allocation for the new file, and obviously the OS can "forget" the sheet that was deleted.

This is only a theory of mine, but it makes sense given some of the other issues with Microsoft products.

Another example is Access, which has a "container" issue that becomes corrupt over time.  I've also noticed that if I create and delete tables--even though my overall database hasn't changed in size--the entire file grows and grows and GROWS as I keep deleting and replacing the SAME data!

Hope that helps,

DrewK
Assisted Solution
 
12.09.2004 at 10:27AM PST, ID: 12786018

Rank: Genius

Hi smeden,
If your scrollbar goes way past your data (lots of scrollbar travel left, even though you are at the bottom of the data), then you need to clear the blank rows and columns beyond the range of your data.

Go to the bottom row of data, then select the entire next row by clicking on the row number. Then CTRL + Shift + Down Arrow to select all the remaining rows in the worksheet. Use the Edit...Clear menu item to clear the rows of values and formats.

Next, go to the rightmost column of data, then select the entire next column by clicking on the column letter. Then CTRL + Shift + Right Arrow to select all the remaining columns in the worksheet. Use the Edit...Clear menu item to clear the columns of values and formats. As an option, you may want to select cell A1 (CTRL + Home in Excel 2002 + earlier; Home in Excel 2003).

Repeat the above procedure for each worksheet that has problems with the scrollbar extending past the data. Then Save the workbook. Close the workbook. Reopen the workbook, and the scrollbars should now extend only as far as the data.

In VBA, you can reset the scrollbar without saving, closing and reopening (once the unused range has been cleared) by executing a statement that uses ActiveSheet.UsedRange.Rows.Count

Macro to automate the previous process:
Sub ExcelDiet()
    Dim ws As Worksheet
    Dim LastRow As Long, LastCol As Long
    Application.ScreenUpdating = False
    On Error Resume Next
    For Each ws In ActiveWorkbook.Worksheets
        With ws
            LastRow = .Cells.Find(What:="*", After:=.Range("A1"), LookIn:=xlValues, _
                LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
            LastCol = .Cells.Find(What:="*", After:=.Range("A1"), LookIn:=xlValues, _
                LookAt:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
            Range(.Cells(1, LastCol + 1), .Cells(65536, 256)).Delete
            Range(.Cells(LastRow + 1, 1), .Cells(65536, 256)).Delete
            LastRow = .UsedRange.Rows.Count
        End With
    Next ws
     On Error GoTo 0
    Application.ScreenUpdating = True
End Sub

Cheers!
Brad
Assisted Solution
 
12.09.2004 at 10:30AM PST, ID: 12786033
smeden,
This is something i usually do.
I save the file in an earlier version of excel.

That's how u do it:
1. Click on file > Save as > Save as type > 95/5.0 excel document

This will reduce the size of file sustantially a decrease of 25% is no big deal.

WARNING! * You must take care that there should be not type of special formatting. If its normal data entry job its not going to create troubles but if it is something which has lotsa flashes n decorations it might have half features installed.

Hope the problem is solved.

Cheers!
Tapan Khatri.
Assisted Solution
 
12.09.2004 at 11:20AM PST, ID: 12786464

Rank: Guru

In addition to what already been said I make it simple and easy for me by moving all data etc into a new workbook.

One other approach is to replace any eventuall array-formulas (both built-in and owned created) with simplet formulas although they require more space in the sheet(s).

Anyway, Charles William's excellent tool, FastExcel, is one tool that can analyze worksheets and workbooks and who also have some good information about memory & Excel:

http://www.decisionmodels.com/index.htm

Kind regards,
Dennis
 


 
12.10.2004 at 12:21AM PST, ID: 12790524
Hi folks,
thank you all. Now I have tried all your suggestions. But still I am not satisfied. I have two workbooks which are quite similar, as they are based on the same workbook. Each of them contains 1 sheet with about 2600 filled cells. 245 cells contains formulas. Formatting of cells are quite similar.
No cells have text >255 characters.
                                File1        File2
Size (Excel2000)      4166 kb    1384 kb
Size (Excel5.0/95)    3587 kb    1196 kb  
All text count            19780       31920

This means that there must be other diffenences. It should be possible to reduce the size of File1 much.
Do you have more suggestions?
 
12.10.2004 at 03:31AM PST, ID: 12791280

Rank: Guru

Smeden,

First of all, You have managed to reduce the filesize with around 75 %. The pareto-statement says 80/20 so from my point of view it's obvious that to get the 20% the effort will probably not be proportional to the remaining percent.

What kind of formulas are in use in the 245 cells?

Is it possible for You to upload the samplefiles somewhere?

Kind regards,
Dennis
 
12.10.2004 at 04:23AM PST, ID: 12791531
Dennis,
I have NOT managed to reduce the filesize of File1 to the size of File2. I think this might be possible, as the two files are so similar. I ask for a reason why File1 is so much larger than File2, and a method to reduce the filesize.

The formulas are all of a kind called DHENT() in Norwegian. I haven't found the English syntax, but the description is: Extracts a single value which fulfill the conditions you indicate, from a column in a list or database.

I do not know how to upload the files.

 
12.10.2004 at 07:30AM PST, ID: 12793053

Rank: Guru

smeden,

It's quite similar name in Swedish: DHÄMTA()

In english the function-name is DGET().

Anyway, You may send the files to my e-mailaddress - see my profile.

Kind regards,
Dennis
Accepted Solution
 
04.20.2005 at 07:38AM PDT, ID: 13824882
Check the Row Height for the last row in your UsedRange.

This worked for me, although it is probably not your problem, since you seem to have got to the bottom of your UsedRange issues, but other readers of this thread may benefit!

In my case I had a worksheet with a UsedRange extending to row 65536 for no apparent reason.  The workbook was huge, and the scrollbars pretty useless.  I tried all of the usual suspects (such as discussed above) to no avail.  Whatever I did I could not reset the UsedRange sensibly.

In the end I discovered that the Row Height is not reset when you do Edit > Clear > Formatting (or > All), and this can cause the UsedRange to extend to the last row that has a non-standard Row Height.  So,  as well as clearing all data and formatting from your unused cells, ensure that they do not have a non-standard row-height setting.

In my case, this reduced the size of my workbook from 5.5M to 680K, and I only discovered it by saving the file as XML and inspecting the XML - you may find some clues to your problem by doing this.

AndyB
 
04.20.2005 at 07:53AM PDT, ID: 13825129

Rank: Genius

> the Row Height is not reset when you do Edit > Clear > Formatting (or > All)

This is why I suggest instead of doing this way, highlight the blank rows, right click one of the highlighted rows and choose Delete. This will remove everything.
 
04.20.2005 at 08:16AM PDT, ID: 13825463
Hi MalicUK,

> ...This will remove everything.

Well, I also thought it would, but in my test case with Excel 2003 SP1, it does not.  

My test case has a single sheet containing no data, no formatting, no defined names, no querytables or anything that I can detect.  If I do as you suggest and ...
  select 65536 entire rows,
  delete them all
  select $A$1,
  execute "?ActiveSheet.UsedRange.Rows.Count" in the VBE Immediate window (gives 65536),
  save the workbook,
  exit Excel and reopen the workbook
...
My UsedRange still has 65536 rows.

If I now select all rows and adjust the row height (so they are all the same height), then select A1 again, my UsedRange (using VBE) suddenly has one row, and on saving the file size reduces from 1.5MB to 15KB.

PS: My test case was extracted from a complex workbook I was trying to fix, not created from scratch, and I now find that I can't reproduce it from scratch.  Having spent *many* hours trying to get to the bottom of this, I'm prepared to accept that I've missed something, but I hope this tip may help another reader.

Regards

AndyB
 
05.16.2005 at 07:14AM PDT, ID: 14010508
Dear All:
I have just seen the above and find it Greek.
How can I learn it to understand all this.
Cheers!!!
Jamshed
 
05.16.2005 at 07:36AM PDT, ID: 14010689

Rank: Genius

Jamshed,
1) This question belongs to smeden, who paid the points to open it. When other people try to ask questions in the thread, that is considered "hijacking" and hence inappropriate.
2) This question has been closed, so the only people seeing your comment are those who posted in it originally. If you had a simple question, I am sure they would be glad to offer an explanation. For more complicated issues (such as explaining what everything means), please open a new question. And if you are going to ask a question, asking for an explanation of a brief list of things you don't understand is much more likely to get a good response than one that says "please explain everything".
3) Most of the regulars in this TA have a copy of John Walkenbach's book "Excel 200x Power Programming with VBA". You may find it a useful guide to learning "Greek".
byundt--Excel TA Page Editor
 
05.16.2005 at 09:34PM PDT, ID: 14016090
Sorry.
 
 
20080236-EE-VQP-29