+ Reply to Thread
Results 1 to 3 of 3

Macro to save Excel file with date and time in the file name?

  1. #1
    sonic_d_hog
    Guest

    Macro to save Excel file with date and time in the file name?

    Does someone out there have a macro that when executed would save the current
    Excel spreadsheet in the form "filename-current date-current time.xls" and
    leave the file open for editing? Ideally, I would like to pin the macro to a
    button on the user's toolbar. Thank you for you help in advance.
    Troy

  2. #2
    Bob Phillips
    Guest

    Re: Macro to save Excel file with date and time in the file name?


    With Activeworkbook
    .SaveAs .Filename & "-" & Format(Now,"dd-mmm-yyyy-hh-mm-ss")
    End With

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "sonic_d_hog" <[email protected]> wrote in message
    news:[email protected]...
    > Does someone out there have a macro that when executed would save the

    current
    > Excel spreadsheet in the form "filename-current date-current time.xls" and
    > leave the file open for editing? Ideally, I would like to pin the macro

    to a
    > button on the user's toolbar. Thank you for you help in advance.
    > Troy




  3. #3
    Bruno Campanini
    Guest

    Re: Macro to save Excel file with date and time in the file name?

    "sonic_d_hog" <[email protected]> wrote in message
    news:[email protected]...
    > Does someone out there have a macro that when executed would save the
    > current
    > Excel spreadsheet in the form "filename-current date-current time.xls" and
    > leave the file open for editing? Ideally, I would like to pin the macro
    > to a
    > button on the user's toolbar. Thank you for you help in advance.
    > Troy


    If you already have a file named Xxxxxx-date-time.xls:

    =========================
    Public Sub SaveAsDateTime()

    With ActiveWorkbook
    .SaveAs Left(ActiveWorkbook.FullName, _
    InStr(1, ActiveWorkbook.FullName, "-")) _
    & Format(Now, "yyyymmdd-hhmmss") & ".xls"
    End With

    End Sub
    =========================

    Ciao
    Bruno



+ 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