+ Reply to Thread
Results 1 to 8 of 8

Save file as "mmm-mmm yyyy"?

  1. #1
    Registered User
    Join Date
    06-16-2015
    Location
    Stockholm
    MS-Off Ver
    2007
    Posts
    14

    Save file as "mmm-mmm yyyy"?

    Hello,

    I'm looking for help with, what I thought was a simple thing to do but apparently not for me, to save a file with the format "mmm" of the month 4 months ago, "mmm" of the month 1 month ago, followed by "yyyy" of current year.
    So now in June it would be, "Feb-May 2019". Basically it's the latest quarter, so maybe there is a simplier way to do it?

    This is what I have so far:
    Please Login or Register  to view this content.
    However, I get a "Compile Error: Expected Array" on this "month = Format(DateSerial(month(Date) - 1, 1), "mmm")". I'm not really a pro on this, so any help is appreciated!

    Thanks in advance!

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Save file as "mmm-mmm yyyy"?

    DateSerial needs 3 arguments (year, month, day)

    So maybe:

    Please Login or Register  to view this content.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Registered User
    Join Date
    06-16-2015
    Location
    Stockholm
    MS-Off Ver
    2007
    Posts
    14

    Re: Save file as "mmm-mmm yyyy"?

    Quote Originally Posted by Arkadi View Post
    DateSerial needs 3 arguments (year, month, day)

    So maybe:

    Please Login or Register  to view this content.
    Hmm, aah OK, I still got the same error message even when I changed it though

  4. #4
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,293

    Re: Save file as "mmm-mmm yyyy"?

    change you variables to mymonth,mymonth2,myyear

  5. #5
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Save file as "mmm-mmm yyyy"?

    @nigelog good call.
    @gliori avoid using any function names (or properties) for variables.

  6. #6
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Save file as "mmm-mmm yyyy"?

    Im not sure how you get feb to may as that is 4 months not 3

    I am also wary about using month as a name in vba anything that could be interpreted as something else

    Try adding the below
    Please Login or Register  to view this content.

  7. #7
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,293

    Re: Save file as "mmm-mmm yyyy"?

    Ta, glad to help

  8. #8
    Registered User
    Join Date
    06-16-2015
    Location
    Stockholm
    MS-Off Ver
    2007
    Posts
    14

    Re: Save file as "mmm-mmm yyyy"?

    Quote Originally Posted by davsth View Post
    Im not sure how you get feb to may as that is 4 months not 3

    I am also wary about using month as a name in vba anything that could be interpreted as something else

    Try adding the below
    Please Login or Register  to view this content.
    Thanks a lot, that was a very nice solution!

    And of course, you're right, should be current month-3 and not 4, to current month-1.

    With this code I got it completely right:
    Please Login or Register  to view this content.
    Thanks again all!

+ 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] Make "WeekdayName" Function Work With "dd/mm/yyyy" Format
    By KMVKMVKMV in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-30-2019, 02:30 PM
  2. Replace date in "DD.MM.YYYY" with date "DD/MM/YYYY" format as soon as user hits enter
    By abhinavbinkar in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-14-2019, 09:12 AM
  3. Replies: 2
    Last Post: 11-15-2018, 06:03 PM
  4. [SOLVED] Script to save to folder in "v:\dept2", confirm file saved, then delete from "v:\dept1"
    By ks100 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-28-2014, 11:42 AM
  5. [SOLVED] Convert from "general" (YYYYMMDD) to specific "custom" format (YYYY.MM.DD)
    By Ella_p in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-10-2013, 02:23 AM
  6. Replies: 0
    Last Post: 08-09-2012, 04:31 PM
  7. Saving a file to a "YYYY" and "MMM" folder
    By hriggs in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-10-2008, 07:00 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