+ Reply to Thread
Results 1 to 13 of 13

AUTOFILTER causes the file size to increase

  1. #1
    Forum Contributor
    Join Date
    08-04-2005
    Location
    Madrid, Spain
    MS-Off Ver
    2010
    Posts
    241

    AUTOFILTER causes the file size to increase

    I see there are many posts in this Forum dealing with size-increasing macros, most of them blaming it on unused rows, cells or blanks. That’s not the case for me now.
    I think I’ve tracked the cause to the Data/Filter function of Excel (or perhaps to the Data/Subtotal function???). Here:

    My file is a list of rows with figures in one column, and also with subtotal rows from time to time (these have been obtained by some previous code in my macro calling for the Data/Subtotal function of Excel).
    Now, further down, some other code lines in the macro filter the list to show only the rows beginning with “Total” or, alternatively, showing all lines; here is the filtering code:
    Please Login or Register  to view this content.
    That works O.K., but the size of my file may increase by about one megabyte, depending on when I save it, thus:

    - If I save my list for the FIRST TIME after running the filtering macro lines (that is, with only the Subtotal rows shown), then the size of the file will be increased by a mega.
    And even if subsequently I unfilter my list and save it again as unfiltered (that is, with all rows visible), the size will remain so increased.

    - But if I save the list for the FIRST TIME before running the filtering macro lines (while still showing all the rows), then the size won’t be increased at all.
    And even if subsequently I filter the list and save it again as filtered (that is, with only the Subtotal rows visible), the size will still remain unincreased.

    - Finally, if I do the filtering MANUALLY (not by executing the macro), then the size of the file will never increase in size, whether I do the first saving with the list filtered or unfiltered.

    Is all this just a confusing mess or does it suggest a possible remedy to you, experts out there? Thank you in advance.
    ACA
    Last edited by aca; 07-10-2011 at 11:49 AM.

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    I doubt it

    Avoid using select and activate in VBA.

    Please Login or Register  to view this content.



  3. #3
    Forum Contributor
    Join Date
    08-04-2005
    Location
    Madrid, Spain
    MS-Off Ver
    2010
    Posts
    241

    Re: AUTOFILTER causes the file size to increase

    Thanks, snb.
    But the code you give doesn't seem to perform any filtering in my file; I am not using it properly, no doubt. Thanks anyway.
    ACA

  4. #4
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: AUTOFILTER causes the file size to increase

    Are you sure any cell in column C contains 'total' ?

    The code must be put into the macromodule of the sheet you want to filter.

  5. #5
    Forum Contributor
    Join Date
    08-04-2005
    Location
    Madrid, Spain
    MS-Off Ver
    2010
    Posts
    241

    Re: AUTOFILTER causes the file size to increase

    Thank you for not giving up.
    Yes, to both your questions: in fact, I tried substituting your code lines for mine own in my macro.
    Only that in my original message I copied my 2 code lines with an error; what I have, actually, is this (not the word "selection")
    Please Login or Register  to view this content.
    I Think that's what I got when recording the actual steps for the filtering function.
    Thanks again.
    ACA
    Last edited by aca; 07-10-2011 at 03:00 PM.

  6. #6
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    converting disbelievers

    Since you don't give the impression to be inclined to post a sample workbook, cfr. the attachment.
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    08-04-2005
    Location
    Madrid, Spain
    MS-Off Ver
    2010
    Posts
    241

    Re: AUTOFILTER causes the file size to increase

    Thanks again for your efforts.
    Pls, do not misinterpret me: I didn't include a sample bcs it thought it would be little use, as my actual file is very complex and so is the chain of seven long macros that manage it to make it perform as an accounting program. (in Spanish, at that).
    But here are a few lines of the Worksheet in question, with one macro to which I've copied your code.

    Anyway, when I've tried my query with just a few lines and only this piece of code in isolation, my file did never increase in size as it happens with my real complex file.
    Thanks again.
    ACA
    Attached Files Attached Files

  8. #8
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: AUTOFILTER causes the file size to increase

    Ergo:

    - the size has nothing to do with autofilter
    - autofilter works independently of 'empty' cells

    I don't bother reading and understanding Spanish.

    Most of the time the file size is due to a difference between 'usedrange' and the range containing real values.

    You can test that with
    Please Login or Register  to view this content.
    You can reduce the sheet to the range containing real values using the hyphenated code. Save the workbook; you will notice it's size has been reduced (probably drastically).

  9. #9
    Forum Contributor
    Join Date
    08-04-2005
    Location
    Madrid, Spain
    MS-Off Ver
    2010
    Posts
    241

    Re: AUTOFILTER causes the file size to increase

    snb, I am overwhelmed by your perseverance. Thanks a world.

    Your latest code scans my worksheets all right, But there's no excess space detected.

    I guessed it was so (and now your code confirms it objectively), that's why I assumed that the extra size might happen because the filtering function introduced or superimposed something like a second sheet on top of the original one showing all rows.
    But since you state that it is not so, I would simple give up and put up with that anomaly when it occurs.

    Still, it would be nice if your alternative code for the autofiltering function was applied to the sample lines I attached for you to see, for just now your code, as I pasted it in the macro included in the attached file, fails to run. Perhaps your code would not cause the increase in size that mine does.

    In any case, I am grateful for your efforts to help me; God bless you for so much good will.
    ACA

  10. #10
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: AUTOFILTER causes the file size to increase

    Please do not introduce religious stuff in a non religious forum.

    You could have mentioned you wanted to filter on 'totales' in cells that contain more information. Cfr the attachment.

    I stated before: The code must be put into the macromodule of the sheet you want to filter
    But you didn't.

  11. #11
    Forum Contributor
    Join Date
    08-04-2005
    Location
    Madrid, Spain
    MS-Off Ver
    2010
    Posts
    241

    Re: AUTOFILTER causes the file size to increase

    Thank you again, snb.
    As for the"religious stuff", no offense intended; it was meant and used just as a common expression of good will towards you. Beg your pardon if I hurt your feelings.

    For the code, you're right; I failed to put it in the right place; that'll be corrected immediately.

    Thanks again for following my query so adamantly. I duly added to your reputation in that sense.
    ACA

  12. #12
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: AUTOFILTER causes the file size to increase

    In my previous post I forgot to add the attachment.
    Attached Files Attached Files

  13. #13
    Forum Contributor
    Join Date
    08-04-2005
    Location
    Madrid, Spain
    MS-Off Ver
    2010
    Posts
    241

    Re: AUTOFILTER causes the file size to increase

    Yes, I saw that the star was to be added to your original code (cell beginning with....)
    Again, everything I expressed in recognition.
    ACA

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1