+ Reply to Thread
Results 1 to 5 of 5

Save file with ISO correct Workweek

Hybrid View

matt4003 Save file with ISO correct... 01-12-2010, 03:49 PM
Leith Ross Re: Save file with ISO... 01-12-2010, 04:17 PM
matt4003 Re: Save file with ISO... 01-12-2010, 04:29 PM
Leith Ross Re: Save file with ISO... 01-12-2010, 04:35 PM
matt4003 Re: Save file with ISO... 01-12-2010, 04:38 PM
  1. #1
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Save file with ISO correct Workweek

    Hello Matt,

    Since the ISO 8601 week and the Gregorian calendar week are not identical, you will need to use a conversion function to return the correct ISO week.

    From Chip Pearson's site http://www.cpearson.com/excel/WeekNumbers.aspx
    Public Function IsoWeekNumber(InDate As Date) As Integer
        Dim D As Long
        D = DateSerial(Year(InDate - Weekday(InDate - 1) + 4), 1, 3)
        IsoWeekNumber = Int((InDate - D + Weekday(D) + 5) / 7)
    End Function
    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!)

  2. #2
    Forum Contributor
    Join Date
    05-18-2004
    Location
    Portland, Oregon
    MS-Off Ver
    2016
    Posts
    182

    Re: Save file with ISO correct Workweek

    Hi Leith!

    Thanks for the reply.

    I guess I don't know exactly how to insert that into my code....or reference that Function in my ActiveWorkbook.SaveAs statement....

    I put the new Public Function in Module 1 above the ActiveWorkbook.SaveAs Sub, but what do I change on my
    Format(Date, "WW", vbUseSystemDayOfWeek, vbUseSystem)
    Thanks again for your help!

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

    Re: Save file with ISO correct Workweek

    Hello Matt,

    Copy Chip's code in a standard VBA Module. Add this line where you need it...
    ActiveWorkbook.SaveAs Application.UserName & "_" & "FCST" & "_" & Format(Date, "MMDDYYYY") & "_" & "CW" & IsoWeekNumber(Date)

  4. #4
    Forum Contributor
    Join Date
    05-18-2004
    Location
    Portland, Oregon
    MS-Off Ver
    2016
    Posts
    182

    Re: Save file with ISO correct Workweek

    Thanks Leith! I was so close, just missed the last part of "(Date)".

    Works great!

    I will close the thread as Solved.

    Cheers,
    Matt

+ 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