+ Reply to Thread
Results 1 to 13 of 13

How do I save to a folder that is the current month and have it save to next month"

  1. #1
    Registered User
    Join Date
    06-25-2014
    Location
    Alberta, Canada
    MS-Off Ver
    2010
    Posts
    19

    How do I save to a folder that is the current month and have it save to next month"

    Hi! Here is a macro I am using to save a workbook using 'Save As' (I can't take credit for the full macro. A forum member was kind enough to help me with it. The only part I added was the 'Open' portion.)
    I have it open a template workbook we use, and then perform a save as, pathed to a specific folder on the desktop. We do this every night just before midnight.
    What I haven't been able to figure out is how to have it save to the next month folder (The folders with the name of all the months are already created) on the last day of each current month.

    For example. In my code, the final folder in the path is the current month July. On July 31 when I run the macro, I would like it to save it in the folder called August.

    Is there a way to code this so it will recognize what the current month is and then at the end of each current month save it in the next month?

    Here is my code.

    Thank you in advance.

    Please Login or Register  to view this content.
    Last edited by shikano53; 07-16-2014 at 10:56 AM. Reason: Solved

  2. #2
    Forum Contributor prabhuduraraj09's Avatar
    Join Date
    05-19-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    330

    Re: How do I save to a folder that is the current month and have it save to next month"

    Hi Shikano53,

    I have given a try. Below code is un tested........Give a try

    what i did here is, i have formated current date to suit your monthly folder name "JULY" or "August" etc.,
    Hope that is your monthly folder name..... having the current date + 1 ...that is next day......it take month as consideration as folder name for file to get saved.
    So if the last day of month comes, folder name would be next month...Then file would get saved in next month folder.

    Hope it helps......


    HTML Code: 
    If my answer helps you... Please add "Reputation" for my post....if you are happy with the help.

  3. #3
    Registered User
    Join Date
    06-25-2014
    Location
    Alberta, Canada
    MS-Off Ver
    2010
    Posts
    19

    Re: How do I save to a folder that is the current month and have it save to next month"

    Quote Originally Posted by prabhuduraraj09 View Post
    Hi Shikano53,

    I have given a try. Below code is un tested........Give a try

    what i did here is, i have formated current date to suit your monthly folder name "JULY" or "August" etc.,
    Hope that is your monthly folder name..... having the current date + 1 ...that is next day......it take month as consideration as folder name for file to get saved.
    So if the last day of month comes, folder name would be next month...Then file would get saved in next month folder.

    Hope it helps......


    HTML Code: 
    If my answer helps you... Please add "Reputation" for my post....if you are happy with the help.
    Hi,
    Sorry, no that does not work. Let me try and clarify if I can.
    My original code works fine as long as the last folder I want to save to is 'July'.
    What I want the code to do is to be dynamic enough to be able to determine that the next days date will be the first day of the next month and then save it in the folder named for the next month of the year.
    For example. On July 31, when I run the macro, I would like the macro to be able to 'Save As' and place the saved workbook in a folder called August.
    I hope that helps explain what I am trying to do.
    All of the month folders are in a folder named '2014'
    So that means in the folder named 2014 there are sub folders for each month. January, February, March, April - December.

  4. #4
    Forum Contributor prabhuduraraj09's Avatar
    Join Date
    05-19-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    330

    Re: How do I save to a folder that is the current month and have it save to next month"

    Hi Shikano,

    Apologise, i have done some tweaking now.......

    If you see your file name "original log..xlsm" in code update with ".."before extension. ( Please check if that is correct )

    Please replace the root path & your original log file appropriately & change file extension

    in my comp with test path "It worked", i set my comp date to last date of month.........its working fine.
    And then test in your system.
    HTML Code: 
    tried to add your path in my code...... please check before you give a try
    updated file name as "original log.xlsm".....hope its correct!

    HTML Code: 

    If This code helped you achieve your requirement, please do add Reputation for me...... "Thank you"

  5. #5
    Registered User
    Join Date
    06-25-2014
    Location
    Alberta, Canada
    MS-Off Ver
    2010
    Posts
    19

    Re: How do I save to a folder that is the current month and have it save to next month"

    Hi Pradhuduraraj09,
    I am looking at your code now.
    Not sure what you mean by 'If you see your file name "original log..xlsm" in code update with ".." before extension

    Before I run the test I have a quick question.
    Did you create a folder on your path called August so that the file is then saved to that folder etc.
    Thank you again for your kind help. If this works I will add Reputation for you.
    Kind regards
    Last edited by shikano53; 07-15-2014 at 12:11 PM.

  6. #6
    Forum Contributor prabhuduraraj09's Avatar
    Join Date
    05-19-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    330

    Re: How do I save to a folder that is the current month and have it save to next month"

    Hi Shikano53,

    the file name which you have mentioned in the code is "origina log..xlsm". which had dots in between.
    Never mind. Just make sure, you check path and file name is appropriate.

    And yes i did created folder name as August for testing purpose.

    Well thank you, Hope it helps you.

  7. #7
    Registered User
    Join Date
    06-25-2014
    Location
    Alberta, Canada
    MS-Off Ver
    2010
    Posts
    19

    Re: How do I save to a folder that is the current month and have it save to next month"

    Thank you,
    Code works except it keeps opening a file called Chris.xlsm and I don't know why it does that. When I moved the file Chris.xlsm to a backup folder and ran the macro it gave me an error that said:

    error.JPG

    Also, when I tried the program at work with the following paths instead of my home path it only opened the original file and did not save it.
    Here are the actual paths I need that I use at work.

    C:\Users\Security\Desktop\Daily Logs DO NOT DELETE ‘ Root path for monthly folders
    C:\Users\Security\Desktop\Original Forms ‘ file path of template excel file

    Thank you and I'm sorry to bother you again.
    Chris

  8. #8
    Forum Contributor prabhuduraraj09's Avatar
    Join Date
    05-19-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    330

    Re: How do I save to a folder that is the current month and have it save to next month"

    Hi Shikano53,

    Not a problem, i am happy to help you as much as possible.

    would you be able to post the code, in which you are facing the above said issues?

    will definitely have a look at it. Guess we are close to solution

  9. #9
    Registered User
    Join Date
    06-25-2014
    Location
    Alberta, Canada
    MS-Off Ver
    2010
    Posts
    19

    Re: How do I save to a folder that is the current month and have it save to next month"

    Quote Originally Posted by prabhuduraraj09 View Post
    Hi Shikano53,

    Not a problem, i am happy to help you as much as possible.

    would you be able to post the code, in which you are facing the above said issues?

    will definitely have a look at it. Guess we are close to solution
    Yes, thank you so much!
    Here is the code.

    Please Login or Register  to view this content.

  10. #10
    Forum Contributor prabhuduraraj09's Avatar
    Join Date
    05-19-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    330

    Re: How do I save to a folder that is the current month and have it save to next month"

    Hi Shikano53,

    Please give a try with the below code,

    HTML Code: 

  11. #11
    Registered User
    Join Date
    06-25-2014
    Location
    Alberta, Canada
    MS-Off Ver
    2010
    Posts
    19

    Re: How do I save to a folder that is the current month and have it save to next month"

    [QUOTE=prabhuduraraj09;3768632]Hi Shikano53,

    Please give a try with the below code,

    That is AWESSOME! It works perfect!
    Thank you so much for your kind help and for being patient with me!
    Chris

  12. #12
    Forum Contributor prabhuduraraj09's Avatar
    Join Date
    05-19-2012
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    330

    Re: How do I save to a folder that is the current month and have it save to next month"

    Hi Chris,

    Happy it worked for you. Thanks for your patience as well
    Glad i helped you.

    Could you please Rate this thread and Tag this thread as "Solved".

    Do PM me if you post any future question in Forum.

    see you

  13. #13
    Registered User
    Join Date
    06-25-2014
    Location
    Alberta, Canada
    MS-Off Ver
    2010
    Posts
    19

    Re: How do I save to a folder that is the current month and have it save to next month"

    Thank you for your help.
    I have tagged the thread 'solved' and I also rated it was well.

    Kindly

+ 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. How to save file in respective month folder as per current year vba modification
    By KK1234 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-03-2014, 05:26 PM
  2. Replies: 4
    Last Post: 09-09-2013, 05:06 AM
  3. [SOLVED] Save invoice to folder by month and then save file by date and invoice
    By Val777 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-03-2013, 02:57 AM
  4. [SOLVED] Macro to Save a PDF in folder by month
    By tomisthereason in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-25-2013, 05:06 AM
  5. [SOLVED] macro to save file in current month
    By vivek_work in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-16-2013, 07:07 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