+ Reply to Thread
Results 1 to 9 of 9

Save As by date

  1. #1
    Forum Contributor
    Join Date
    05-27-2012
    Location
    New Brunswick, Canada
    MS-Off Ver
    Excel 2016
    Posts
    349

    Save As by date

    Every Saturday I need to save 7 files, each having a file name with the dates of the upcoming week (our work week starts on a Saturday). Is there a "Save As" type macro I can create - something like Current Date, Current Date+1, Current Date+2, etc...?

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Save As by date

    Hi, Wheelie686,

    maybe this sniplet may give you an idea of how to solve the problem:
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Forum Contributor
    Join Date
    10-18-2012
    Location
    Telford, England
    MS-Off Ver
    Excel 2010 (2003)
    Posts
    294

    Re: Save As by date

    Please Login or Register  to view this content.
    This saves the files as (e.g.) 30 Oct 2012.xls but you can change the format to suit and precede with a constant if you need.

  4. #4
    Forum Contributor
    Join Date
    05-27-2012
    Location
    New Brunswick, Canada
    MS-Off Ver
    Excel 2016
    Posts
    349

    Re: Save As by date

    Thank you brynbaker. That somewhat does what I want but two issues I would not have expected.
    1. It will not let me save where I want, it defaults to a hidden Excel directory on my PC.
    2. The name I want to use is (for today for example) is Aliant Intraday Report Avaya 2012-10-27 but it came out Alia0t I0tra27a301 Report Ava301a 2012-10-27. It's like it has problems with the letters N, D and Y. I can't say I've ever seen that before lol.

  5. #5
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Save As by date

    Hi, Wheelie686,

    It will not let me save where I want, it defaults to a hidden Excel directory on my PC.
    Is this place a given folder or do you want to choose it from time to time?

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    It's like it has problems with the letters N, D and Y.
    Sure, as in the format function these are laid out for Months, Days, and Years. As you didnīt the post probably you included the whole of the variable into the format string?

    Ciao,
    Holger

  6. #6
    Forum Contributor
    Join Date
    05-27-2012
    Location
    New Brunswick, Canada
    MS-Off Ver
    Excel 2016
    Posts
    349

    Re: Save As by date

    HaHoBe - I would actually like to pick where I want to save it even though I'll probably end up putting it in the same place every week.

    The code I have now is:

    Please Login or Register  to view this content.

  7. #7
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Save As by date

    Hi, Wheelie686,

    there you are - if you use the whole name inside the format you have to mask the characters so that VBA will not replace them. Iīd preferred to split things up into two parts - the name and the date part (no worry for VBA changing characters there).

    Copy and insert the following function into your module:
    Please Login or Register  to view this content.
    And alter your code to read
    Please Login or Register  to view this content.
    Ciao,
    Holger

  8. #8
    Forum Contributor
    Join Date
    05-27-2012
    Location
    New Brunswick, Canada
    MS-Off Ver
    Excel 2016
    Posts
    349

    Re: Save As by date

    That worked for the macro that will save Saturday's report but yet when I copy it to create the following days' reports, knowing I have to add + 1,2,etc.. then it doesn't run. The two should be nearly identical, with the excetion of the + 1.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  9. #9
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Save As by date

    Hi, Wheelie686,

    try this (sorry but I did just realize that the counter was identical to the values which where used):
    Please Login or Register  to view this content.
    There will be the question to overwrite if the file already exists - I already had created the first files and had them replaced.

    Ciao,
    Holger

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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