Results 1 to 6 of 6

Filename as PRIOR month

Threaded View

  1. #1
    Registered User
    Join Date
    11-30-2007
    Location
    Edinburgh, UK
    MS-Off Ver
    2003
    Posts
    84

    Filename as PRIOR month

    Hi,

    I'm trying to get a bit of code to name a file as the prior month. I searching this forum and many others, as well as excel help, and even asked our traning department in work, all to no avail.

    Does anyone know how I can get this to work?

    This is what I have:

    
    Sub save()
    
    Dim myPath As String, lastday As String
        myPath = ActiveWorkbook.Path
    'lastday need to be the end of the prior month in yyyymmdd format, so far only saves as current date in yyyymmdd format (need to work for year end as well)
        lastday = Format(Now(), "yyyy") & Format(Now(), "mm") & Format(Now(), "dd")
    'which could be lastday = Format(Now(), "yyyymmdd") I know, but I was working on trying to get it to work.
          
        ActiveWorkbook.SaveAs Filename:= _
        myPath & "\Final_RP_Barra_Preprocessor_TEST " & lastday & ".xls"
    
    End Sub
    Cheers
    Last edited by VBA Noob; 05-23-2008 at 11:00 AM.

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