+ Reply to Thread
Results 1 to 5 of 5

Open a template, make some changes to cells and then save the file

  1. #1
    Forum Contributor
    Join Date
    01-15-2013
    Location
    London
    MS-Off Ver
    Excel 2003, 2007, 2010, 2019
    Posts
    436

    Open a template, make some changes to cells and then save the file

    Hello everyone,

    I am thinking of making a macro which will open a template and change values to some cells. After the calculation is complete, I will save / close the file to a folder. I will repeat this process for 20 times: open the template, make changes to some cells and then save / close.

    My question is: how can I know if the automatic calculation has been completed before the file is saved and closed? Do I need to reserve a time gap of say, 5 mins before I am really sure the calculation is done?

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,813

    Re: Open a template, make some changes to cells and then save the file

    I guess that would depend on what the calculations are and how many there are. Most simple formulae will calculate instantly. But, if your Template has a large number of complex formulae with full column references and or array formulae, it can take a while.

    How will you automate entering 20 sets of data?

    Suggest you post a copy of the template and indicate what values you would be changing.


    Attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Contributor
    Join Date
    01-15-2013
    Location
    London
    MS-Off Ver
    Excel 2003, 2007, 2010, 2019
    Posts
    436

    Re: Open a template, make some changes to cells and then save the file

    Sorry to ask again. Thanks for the advice of the experienced.

    If I ask the macro to open the spreadsheet, make changes to some cell values and then immediately ask the macro to save / close the file, what will happen to the results in the spreadsheet? Will the spreadsheet be closed immediately, or it will wait until the automatic calculation is completed? I need to understand how it works in this case.

  4. #4
    Valued Forum Contributor
    Join Date
    01-19-2010
    Location
    Melbourne Australia
    MS-Off Ver
    latest is Excel 2016. have older versions
    Posts
    624

    Re: Open a template, make some changes to cells and then save the file

    Hi billj,

    the statement "ActiveWorkbook.Save" will wait until the workbook has actually saved which will be after the calculations have concluded.

    You could consider setting the calculation options in such a way that automatic recalculation is disabled and only performed on workbook saved. If you calcs are extensive this would make the process faster for end to end

    Hope this helps however as Trevor suggested / requested you should post an example workbook as he described, most of us do not have the time to "build a spreadsheet that matches what we think you are asking"

    Cheers

    Cheers

    Jmac1947

    1. Please consider clicking on the * Add Reputation if you think this post has helped you
    2. Mark your thread as SOLVED when question is resolved

  5. #5
    Forum Contributor
    Join Date
    01-15-2013
    Location
    London
    MS-Off Ver
    Excel 2003, 2007, 2010, 2019
    Posts
    436

    Re: Open a template, make some changes to cells and then save the file

    Many thanks, everyone. It is good to know that the .Save will wait until the calculation has concluded.

    I also found an article which uses the Application.CalculationState property to check if the calculation is done. The link is:

    HTML Code: 

+ 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. Word Template New Document Save on Open
    By kreiner2006 in forum Word Programming / VBA / Macros
    Replies: 1
    Last Post: 02-13-2019, 08:25 PM
  2. [SOLVED] VBA Open File/Run Macro/Close &Save/Open Next File
    By JPSIMMON in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-21-2015, 12:16 PM
  3. [SOLVED] Macro to open a Template and save a new workbook
    By Keibri in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-11-2015, 02:59 PM
  4. Replies: 2
    Last Post: 05-07-2014, 08:38 AM
  5. Macro to extract a tab from one file, add it to a master template file and then save as
    By SweetSorcery in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-03-2014, 11:36 AM
  6. Replies: 2
    Last Post: 05-20-2011, 07:26 AM

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