+ Reply to Thread
Results 1 to 5 of 5

Using the Current Month, Date, and Time in a Folder Path in VBA Code

  1. #1
    Registered User
    Join Date
    05-11-2013
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    3

    Using the Current Month, Date, and Time in a Folder Path in VBA Code

    I’m working on a project using Microsoft Excel 2010 and I want to add some features to facilitate saving and retrieving files process. My experience in excel is developing and would like to learn and sharing ideas in this matter through these queries:
    1. How can I save the daily created workbooks (Assume 15 files a day) in order to contain the current date (and time if possible) linked with certain cell(s) I have at my workbook forming the file name? (XYZ 2-4-2014) and/or (ABC 2-4-2014 23:11) and so on … I believe using macros will be to key but I want somebody help me out please.
    2. I’ve been through some other posts and I found VB code which saves the active file into specific path, but it is only useful for single workbook because multiple files are getting overwritten automatically. Is there a code which allows multiple/different files saving & creates daily folders?

    Please Login or Register  to view this content.


    I hope these two pints are clear enough with the Code ….. Many Thanks!
    Last edited by vlady; 02-04-2014 at 08:03 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Using the Current Month, Date, and Time in a Folder Path in VBA Code

    Hello anas_hilow,

    Welcome to the Forum!

    To better understand your problem and help you, you should post your workbook and include some before and after examples of the data results. If your workbook contains sensitive information, please redact it before posting.

    How To Post Your Workbook
    1. At the bottom right of the Reply window, Click the button Go Advanced
    2. At the top of the Your Message Window, in the first row of icons, Click the Paperclip icon.
    3. Click the Add Files button at the top right in the dialog box. This displays the File Manager dialog.
    4. Click the Select Files button at the bottom middle of the dialog.
    5. In the new window Find the file you want to upload, select it, and Click Open.
    6. You will now be back in the File Manager dialog. Click the bottom Middle button Upload File.
    7. Wait until the file has completely uploaded before you exit the File Manager dialog.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    05-11-2013
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    3

    Smile Re: Using the Current Month, Date, and Time in a Folder Path in VBA Code

    I have attached the file which I need to work on ... The VB code is valid to save single file, and I want to save many files per day in one folder which name is the current date. Many thanks!

    Quote Originally Posted by Leith Ross View Post
    Hello anas_hilow,

    Welcome to the Forum!

    To better understand your problem and help you, you should post your workbook and include some before and after examples of the data results. If your workbook contains sensitive information, please redact it before posting.

    How To Post Your Workbook
    1. At the bottom right of the Reply window, Click the button Go Advanced
    2. At the top of the Your Message Window, in the first row of icons, Click the Paperclip icon.
    3. Click the Add Files button at the top right in the dialog box. This displays the File Manager dialog.
    4. Click the Select Files button at the bottom middle of the dialog.
    5. In the new window Find the file you want to upload, select it, and Click Open.
    6. You will now be back in the File Manager dialog. Click the bottom Middle button Upload File.
    7. Wait until the file has completely uploaded before you exit the File Manager dialog.
    Attached Files Attached Files

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Using the Current Month, Date, and Time in a Folder Path in VBA Code

    Hello anas_hilow,

    I have tested the macro the below and it works. You should remove the code you have from the ThisWorkbook module and copy the code below into Module1.

    The macro requires the name of a workbook that is open in Excel. It will then save it to the Month folder in the proper Year folder.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-11-2013
    Location
    USA
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Using the Current Month, Date, and Time in a Folder Path in VBA Code

    Leith Ross,

    Thank you for your kind response and concern. I applied the code and it worked, but how can I go into more detailed daily folders? I generate around 15 different files daily and I want to store them into today's folder date and tomorrow's files are stored into tomorrow's folder date and so on extending this to the files themselves too (C:\2014\February\2.6.2014), (C:\2014\February\2.7.2014), (C:\2014\February\2.8.2014) ... etc. Please make sure it doesn't overwrite, cuz I don't wanna loose any.

    Another thing regarding file name; There are many customers listed in the cell "C2" and I want Excel to pull that cell and put it in the beginning of the name and then display the date next to it then followed by the time as 24 hour format (ABC 2.6.2014 07:08), (ABC 2.6.2014 11:23), (ABC 2.6.2014 13:47), (ABC 2.6.2014 18:36), (XYZ 2.6.2014 08:35), (XYZ 2.6.2014 16:04)

    I hope I'm not bothering, but I wish I can learn from you!

    I repeat my thanks and regards.

+ 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. Code to list the folder path and sub folder path of a specific file
    By kalai1587 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-13-2013, 03:51 AM
  2. Code to insert current date (but NOT current time)
    By mjwillyone in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-13-2013, 09:37 AM
  3. Replies: 4
    Last Post: 09-09-2013, 05:06 AM
  4. [SOLVED] add current time (hh:mm:ss) as well as current date (dd:mm:yyyy) into the code
    By papasideris in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-28-2012, 02:29 PM
  5. [SOLVED] Capturing current folder path
    By DKS in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-14-2006, 06:40 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