+ Reply to Thread
Results 1 to 5 of 5

Running this Subroutine Causes my File Size to Increase Dramatically

  1. #1
    Registered User
    Join Date
    03-08-2021
    Location
    Seattle, WA, USA
    MS-Off Ver
    Excel for Mac 16.26
    Posts
    3

    Running this Subroutine Causes my File Size to Increase Dramatically

    I'm running Excel for Mac version 16.46. I have a .XLSM workbook with three worksheets, a small amount of data (approx 100 rows of data in each worksheet), and some VBA code that does some calculations when I enter new data rows. I have one subroutine that protects all but one row in the data entry worksheet to ensure that the user only enters data in one row at a time. The workbook file size is about 200KB, but when I run this subroutine one or more times, the file size increases to 102MB. I assume this problem is related to the fact that I'm protecting a huge block of cells (rows 1 - current row, and current row+1 - 65536). Is there a cleaner way of doing this? The code is pasted below. Thanks in advance for any help you can provide.


    Please Login or Register  to view this content.
    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #2 requires code tags. I have added them for you this time because you are a new member. --6StringJazzer
    Last edited by 6StringJazzer; 03-08-2021 at 09:06 PM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Running this Subroutine Causes my File Size to Increase Dramatically

    You are forcing the size of this sheet to be over 39 million cells even though most of them are probably not being used. That takes up space. I can't tell what you're up to in setting cells to locked, when cells are locked by default. Also, why are you setting colorindex to 0 for the entire worksheet?

    Can you explain in a little more detail what you are trying to achieve so we can consider alternatives?
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    03-08-2021
    Location
    Seattle, WA, USA
    MS-Off Ver
    Excel for Mac 16.26
    Posts
    3

    Re: Running this Subroutine Causes my File Size to Increase Dramatically

    Thanks for the feedback 6String. Here's what I'm trying to accomplish. On this worksheet I only want the user to be able to enter data on the first open line at the bottom of the table. So, if for example the last line of data in the table is line 112, I only want the user to be able to enter data on line 113. I also want to highlight line 113 with a green color. The reason I was setting the colorindex for the whole sheet to 0 was to clear the green color highlight from the previous line of data entry. That was just me being lazy, using brute force rather than determining the previous line number and clearing just that. I hope this makes sense.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Running this Subroutine Causes my File Size to Increase Dramatically

    Quote Originally Posted by faithdm View Post
    That was just me being lazy, using brute force rather than determining the previous line number and clearing just that.
    You want to find the last line of data and just work with that plus the blank line following that. Let me know if you need help to code it.

  5. #5
    Registered User
    Join Date
    03-08-2021
    Location
    Seattle, WA, USA
    MS-Off Ver
    Excel for Mac 16.26
    Posts
    3

    Re: Running this Subroutine Causes my File Size to Increase Dramatically

    Great. Thank you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 2
    Last Post: 08-18-2021, 10:24 PM
  2. Replies: 10
    Last Post: 07-02-2018, 01:59 PM
  3. Excel file size increase
    By moscowpunter in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-12-2016, 12:26 PM
  4. Huge increase in file size
    By Gray in forum Excel General
    Replies: 1
    Last Post: 05-25-2006, 03:55 AM
  5. [SOLVED] File Increase in size
    By Martinj in forum Excel General
    Replies: 7
    Last Post: 11-07-2005, 10:10 AM
  6. The picture use as background increase dramatically the size
    By .·:m·a·r·l·a:&m in forum Excel General
    Replies: 1
    Last Post: 03-11-2005, 10:06 AM
  7. File size increase
    By Bill Clark in forum Excel General
    Replies: 1
    Last Post: 01-28-2005, 03:06 PM

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