+ Reply to Thread
Results 1 to 10 of 10

Need a VBA to save a file upon closing and name it based upon a cell

  1. #1
    Forum Contributor
    Join Date
    05-09-2017
    Location
    NC
    MS-Off Ver
    2013
    Posts
    103

    Need a VBA to save a file upon closing and name it based upon a cell

    As always when I have trouble with excel I turn here but not only has this forum helped me with many problems but also taught me a lot as well so thank you for that.

    My new problem for the day is been a puzzling for me. I need a VBA where upon closing a file, it will make a copy in another folder and name that file based upon some cells inside the sheet. I created a sample sheet with just the basics needed and in this sheet it says "Series 01313". What I would like to have happen is that when this file is closed or "X" out that it will automatically do a save as function to create a file in M:\TEST and that file be named 01313.xlsm.

    Again, thank you for the help and your time.
    Attached Files Attached Files

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,056

    Re: Need a VBA to save a file upon closing and name it based upon a cell

    Place this macro in the code module for ThisWorkbook:
    Please Login or Register  to view this content.
    Please keep in mind that if the location of the numbers changes, the macro will have to be modified.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Forum Contributor
    Join Date
    05-09-2017
    Location
    NC
    MS-Off Ver
    2013
    Posts
    103

    Re: Need a VBA to save a file upon closing and name it based upon a cell

    Thank you! That worked great! I'll mark it as solved and I added reputation. For my own understanding could you tell me which part of the code is associated with i3:m3 so if I ever changed it which line I would need to modify? And one more thing and the I promise I won't bug you anymore about this. What if I wanted to change 01313.XLSM to Release01313.XLSM. Where in the code would I insert that so all the saved files would start with "Release" and then the series number? This helps me out more than you will know with understanding the verbiage.

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,056

    Re: Need a VBA to save a file upon closing and name it based upon a cell

    This will add "Release" to the file name. The 9 represents the column number for column I and the 13 is the column number for column M. So you would only have to change theses column numbers and the row number which in this case happens to be 3. I hope this makes sense. By the way, you're not bugging me. If you have a question, please feel free to ask.
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    05-09-2017
    Location
    NC
    MS-Off Ver
    2013
    Posts
    103

    Re: Need a VBA to save a file upon closing and name it based upon a cell

    Thank you for the bonus work

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,056

    Re: Need a VBA to save a file upon closing and name it based upon a cell

    You are very welcome.

  7. #7
    Forum Contributor
    Join Date
    05-09-2017
    Location
    NC
    MS-Off Ver
    2013
    Posts
    103

    Re: Need a VBA to save a file upon closing and name it based upon a cell

    Mumps1 if I could impose upon you one more time. The code works better perfect for the way you have it but is there a line I can add to it that when someone opens up the file to look at it but does not want to save it, that will prevent it from going into debug mode when selecting "No" when prompted if they want to replace the current copy? I have some employees that are not great with computers (thus the need for the code in the first place)so if the file is visited again and changes do not need to be saved then it will not take it as an error. If not, all good, you helped me out tremendously and I'll just write them down a few instructions to post near the computer.

  8. #8
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,056

    Re: Need a VBA to save a file upon closing and name it based upon a cell

    Try:
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    05-09-2017
    Location
    NC
    MS-Off Ver
    2013
    Posts
    103

    Re: Need a VBA to save a file upon closing and name it based upon a cell

    Thanks for looking into it. This code brings up the save prompt each time and if I open up an existing copy to view it then will only accept "yes" and it may be we open a file to look at something and put some "what if" numbers in there to see the results but do not want ot save the changes. The previous code worked great so I'll just train them on hitting the "end" button on the debug when it pops up.

    Thank you so much Mumps1

  10. #10
    Forum Contributor
    Join Date
    05-09-2017
    Location
    NC
    MS-Off Ver
    2013
    Posts
    103

    Re: Need a VBA to save a file upon closing and name it based upon a cell

    Mumps1 I am starting a new thread because even if you go thru the bother to help me again I can't give you proper reputation for an additional question.

+ 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. [SOLVED] Save Each Worksheet as a PDF File and Name each File Based on a Cell Value in each Sheet
    By hamidxa in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-16-2016, 09:36 AM
  2. [SOLVED] Automatically save data locally (not referencing a server) when closing the file
    By JET2011 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-14-2016, 10:56 AM
  3. [SOLVED] VBA - closing a file without being prompted to save it
    By DD1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-06-2015, 12:48 AM
  4. Save a copy of current .xlsm file without closing the original
    By gezza07 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-24-2013, 08:52 PM
  5. [SOLVED] How do I bypass the message to save when closing a file by macro?
    By sjmpcec@anon.com in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-21-2006, 04:05 PM
  6. [SOLVED] Save on closing file
    By ewagz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-28-2006, 11:25 PM
  7. [SOLVED] Prompt for Save when closing a file
    By J. Kerr in forum Excel General
    Replies: 0
    Last Post: 10-05-2005, 05:05 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