+ Reply to Thread
Results 1 to 3 of 3

Adding date to file save as

Hybrid View

Dylan&Hayden Adding date to file save as 07-16-2008, 01:17 PM
mrice Why not use a function like... 07-16-2008, 05:25 PM
Dylan&Hayden Got it! :) Thanks mrice 07-16-2008, 06:03 PM
  1. #1
    Registered User
    Join Date
    03-08-2008
    Posts
    48

    Adding date to file save as

    I'm using VBA to change some formating in a worksheet and I need to save the file as a different name with today's date - preferably in month only format:

    ActiveWorkbook.SaveAs Filename:="T:\GENERAL\XAA.xls", _
    FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
    ReadOnlyRecommended:=False, CreateBackup:=False

    How can I add in the date in month format so the file created will be titled:
    XAA - June.xls (Using today's date as the file creation date)

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967
    Why not use a function like this

    Function GetCurrentMonth()
    Select Case Month(Now)
        Case Is = 1
            GetCurrentMonth = "January"
        Case Is = 2
            GetCurrentMonth = "February"
         '......
         Case Is = 12
            GetCurrentMonth = "December"
    End Select
    End Function
    I'll leave you to fill in the rest

    ActiveWorkbook.SaveAs Filename:="T:\GENERAL\XAA - " & GetCurrentMonth & ".xls", _
    FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
    ReadOnlyRecommended:=False, CreateBackup:=False

  3. #3
    Registered User
    Join Date
    03-08-2008
    Posts
    48
    Got it!

    Thanks mrice

+ 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