+ Reply to Thread
Results 1 to 15 of 15

Excel file won't save after running macro

  1. #1
    Registered User
    Join Date
    11-06-2019
    Location
    Cleveland, OH
    MS-Off Ver
    2016
    Posts
    7

    Excel file won't save after running macro

    My question might be out of scope for this part of the forum and if it is I don't mind buying points to get my question answered by a professional, just wanted to check here first.

    I'm completely new to VBA and have absolutely no experience with scripts and programming. I was given a project by my boss to create a program that tracks physician procedure completion rates for a clinical trial I'm involved in. Through extensive googling and youtube lessons I was able to create a macro that achieves this task. Everything is in a single module with the Main Sub calling up each individual Sub one at a time.

    Basically all it's doing is copying specific columns in the database and pasting them into sheets where a formula is tallying some total, nothing super complex. The macro runs perfectly fine (takes around 20 minutes to complete), my issue is that when I go to save the file after, Excel crashes. I'm assuming there is something in my macro that is not playing nice but I have no idea what it is and my macro is at 2410 lines.

    Is there any specific script that I should be searching for that could be causing this issue? I'd post the macro except its over 2400 lines and I'm guessing that's a big no no (also I'm a noob and have no idea how to post that cool text box everyone does with their script)

    FYI I'm running Excel 2010 64-bit
    Attached Files Attached Files
    Last edited by Noob-Noob; 11-25-2019 at 06:59 PM.

  2. #2
    Registered User
    Join Date
    11-06-2012
    Location
    Texas
    MS-Off Ver
    O365
    Posts
    27

    Re: Excel file won't save after running macro

    You can attach a file to your post. Make sure to clean out any information you shouldn't share.

  3. #3
    Registered User
    Join Date
    11-06-2019
    Location
    Cleveland, OH
    MS-Off Ver
    2016
    Posts
    7

    Re: Excel file won't save after running macro

    Quote Originally Posted by Daishiknyte View Post
    You can attach a file to your post. Make sure to clean out any information you shouldn't share.
    There's no identifying patient information. Just give me a minute to delete out the physician names and I'll attach the workbook to my original post.

    Edit: Just tried to post the workbook but it's 68mb so too large.

    Edit 2: I was able to attach pretty much the entire macro code in my original post. Can you work off this or do you still need the workbook too?
    Last edited by Noob-Noob; 11-25-2019 at 04:27 PM.

  4. #4
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,517

    Re: Excel file won't save after running macro

    Re: "The macro runs perfectly fine (takes around 20 minutes to complete)"
    That's a matter of opinion of course.
    Had a quick peek at your attached text file, which does do no good at all, and I am sure someone can come up with a much better solution.
    For one thing, selecting is frowned upon because it is mostly not required and slows everything down (hence the 20 min).
    However, kudos for you doing what you did.
    If you attach a thumbed down version of your excel workbook without personal data, someone will have a solution that finishes, if it is slow, in 20 seconds instead of 20 minutes.
    Make sure the workbook is setup like your original. Exp[lain what you want and it would be best if you have a before and after example.

  5. #5
    Registered User
    Join Date
    11-06-2019
    Location
    Cleveland, OH
    MS-Off Ver
    2016
    Posts
    7

    Re: Excel file won't save after running macro

    Quote Originally Posted by jolivanes View Post
    Re: "The macro runs perfectly fine (takes around 20 minutes to complete)"
    That's a matter of opinion of course.
    Had a quick peek at your attached text file, which does do no good at all, and I am sure someone can come up with a much better solution.
    For one thing, selecting is frowned upon because it is mostly not required and slows everything down (hence the 20 min).
    However, kudos for you doing what you did.
    If you attach a thumbed down version of your excel workbook without personal data, someone will have a solution that finishes, if it is slow, in 20 seconds instead of 20 minutes.
    Make sure the workbook is setup like your original. Exp[lain what you want and it would be best if you have a before and after example.
    Haha well when I say fine I mean it gets the job done, clearly the script is very inefficient.

    I just uploaded a before and after version of the workbook file pared down to only two physicians. The goal of the script is to copy over the relevant columns of data from the Procedures_D and Procedures_E sheets into a variety of other sheets in order for it to calculate the total number of each type of procedure completed. There are formulas in the other sheets that calculate these totals. Finally those values are copied over into the full progress sheet to be displayed.

    Is there any other information you think I should provide to help others understand the issue at hand?

  6. #6
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,517

    Re: Excel file won't save after running macro

    Please Login or Register  to view this content.
    That Range is wrong isn't it.

    Please Login or Register  to view this content.
    Where does the 700 come from? Just an arbitrary number so you cover the max possible Columns?

    What should this formula in Column X in Workflow_adherence do?
    Please Login or Register  to view this content.

    Please don't quote whole posts. All extra clutter we don't need. Refer to a Post # if required.
    Last edited by jolivanes; 11-25-2019 at 09:43 PM.

  7. #7
    Registered User
    Join Date
    11-06-2019
    Location
    Cleveland, OH
    MS-Off Ver
    2016
    Posts
    7

    Re: Excel file won't save after running macro

    You are correct, the L is a typo, nice catch!

    The total number of columns for my Procedures sheets is 669. I just set it to go out to 700 in order to cover any additional columns of data being added in the future.

    Please Login or Register  to view this content.
    If the value in cell V4 is 0 it sets the value of the cell to 0, if the value in cell V4 is any number greater than 0 it sets the value to 1. I'm not sure why it looks so funky but it seems to work XP

  8. #8
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,517

    Re: Excel file won't save after running macro

    After you autofiltered "Procedures_D" sheet and run this, does it transfer the right data?
    This is only the part to transfer data. (Above this line: PURPOSE: Find & Replace a list of text/values throughout entire workbook)
    Please Login or Register  to view this content.
    That funky formula could be changed to =If(V4>0,1,0) I think.
    The quotation marks around the 1 makes it text. Is that what you want?

  9. #9
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,447

    Re: Excel file won't save after running macro

    I don't know anything about VBA but in this formula
    Please Login or Register  to view this content.
    "1" is a text string. Shouldn't the double quotes be removed to make it a number?

  10. #10
    Registered User
    Join Date
    11-06-2019
    Location
    Cleveland, OH
    MS-Off Ver
    2016
    Posts
    7

    Re: Excel file won't save after running macro

    Wow that script transferred everything over in a few seconds, that section used to take a few minutes. Thank you so much, I greatly appreciate the help!

    After running with your script the excel file is behaving much better too, I'm now able to save and close out without any issues.

    If it's not too much trouble could you run me through what your script is doing? I have no idea how you identified the proper columns to extract without using the column names? In Sub E I'm using the same inefficient script and I want to apply your script to the sub but I have no idea how to specify the columns to transfer?

    Also you and Pepe were right, that was the correct formula to use, thank you again
    Last edited by Noob-Noob; 11-26-2019 at 10:17 AM.

  11. #11
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,517

    Re: Excel file won't save after running macro

    To avoid possible mistakes when you do it manually, I just did the following.

    Add a sheet to the end in workbook "Full LL Test_Before.xlsm"
    Name it "Temp_Sheet"
    Enter all the names (Column Headers) you need in Cells C1 and down in this Sheet.
    Now run the following code.

    Please Login or Register  to view this content.
    Now you'll have the Column numbers for "Workflow_adherence" in Column B and for "Procedures_D" in Column A

    You can use a similar approach for the other code.

    Do yourself a favo(u)r and Google something like "Why avoid using select in Excel vba"

  12. #12
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,517

    Re: Excel file won't save after running macro

    It looks like to me that lines 203 to 509 could possibly be done with SUMIF Function without filtering.
    I think that you should tackle one problem at the time and Post it in this Forum with a clear and concise explanation what you want to achieve.
    Once one problem is solved, go to the next problem that is dependent on the previous solved one.

  13. #13
    Registered User
    Join Date
    11-06-2019
    Location
    Cleveland, OH
    MS-Off Ver
    2016
    Posts
    7
    Sorry for the late reply, I've been traveling today.

    So correct me if I'm wrong but that script is checking to ensure that the correct columns of data are being copied over from the Procedures_D sheet?

    Thank you for this suggestion, you've already been more helpful than anything I expected. I'll be sure to take further advantage of this forum, it's an incredible resource.

  14. #14
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,517

    Re: Excel file won't save after running macro

    Yes it is.

  15. #15
    Registered User
    Join Date
    11-06-2019
    Location
    Cleveland, OH
    MS-Off Ver
    2016
    Posts
    7

    Re: Excel file won't save after running macro

    I did as you suggested and added the Temp_Sheet. Since I added your script to Sub E as well, I added column checks for the P1_workflow sheet too. I just ran it and everything is running beautifully.

    It could be more efficient of course as you identified between lines 203 and 509 but it's running much faster than before and now it's not overwhelming the systems memory so I'm able to save and exit without excel crashing.

    I'll make another forum post to address the remaining inefficiencies in the macro but you have helped me to solve my main issue. Once more a heartfelt 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: 0
    Last Post: 10-05-2015, 10:45 PM
  2. Running a macro in Excel to set up and save a Powerpoint
    By mithran89 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-19-2015, 02:52 AM
  3. [SOLVED] Excel Crashes when trying to save after running a sort macro
    By jed38 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-09-2013, 09:23 AM
  4. [SOLVED] How to CANCEL file SAVE PROMPT when MACRO is running?
    By Stuart Macro Muppet in forum Excel General
    Replies: 2
    Last Post: 08-11-2005, 08:05 AM
  5. [SOLVED] Re: How to CANCEL file SAVE PROMPT when MACRO is running?
    By Alan in forum Excel General
    Replies: 0
    Last Post: 08-11-2005, 08:05 AM
  6. [SOLVED] when i save xls file, debug script is running and canno't save fil
    By Imtiaz in forum Excel General
    Replies: 1
    Last Post: 07-16-2005, 11:05 AM
  7. How to stop getting the file save box when running a macro
    By Pank Mehta in forum Excel General
    Replies: 1
    Last Post: 03-29-2005, 12:06 PM

Tags for this Thread

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