+ Reply to Thread
Results 1 to 6 of 6

Save Active Sheet to another Workbook

  1. #1
    Registered User
    Join Date
    10-28-2008
    Location
    Ohio
    Posts
    29

    Save Active Sheet to another Workbook

    Hi guys.

    Was curious if there is a way one could. Copy the active sheet that is open in a work book and save it to another file with the date in the name?

    For example Report_11-03-08.xls

    The only problem I see with this. How could I also make it append a letter to report if the file already exits

    Example saved as
    Report1_11-03-08.xls

    Then just continue incrementing.

    Below is all I've come up with so far.

    Thanks

    Sub CopySave()

    Application.ScreenUpdating = False

    ActiveSheet.Copy

    Application.DisplayAlerts = False

    ActiveSheet.SaveAs Filename:=ThisWorkbook.Path & "/" & "Report_" & Format(Date, "mm_dd_yy") & ".xls"


    ActiveWorkbook.Close

    Application.DisplayAlerts = True
    Application.ScreenUpdating = True

    End Sub
    Last edited by Wes28; 11-04-2008 at 11:16 AM.

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,662
    Try this mod:
    Please Login or Register  to view this content.
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    10-28-2008
    Location
    Ohio
    Posts
    29
    protonLeah,

    Thankyou so much worked very well. One question though. Still a little rough for the noob here. Is there a way to keep it indexing if someone saves the file more then twice?

    They may save the file sometimes twice a day. At other times more then 25 times a day.

    Thanks again.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Use the hour of saving as well
    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Registered User
    Join Date
    10-28-2008
    Location
    Ohio
    Posts
    29
    royUK,

    Thanks for your idea. Forgot about the Hour format. Running into a problem with it. Its saving the file as "Report_11_04_08_00.xls". When I step through it again it just over rights the same file. Do you see anything wrong with what I did?

    Thanks Again.



    Sub CopySave()
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    Dim fn As String

    fn = ThisWorkbook.Path & "\" & "Report_" & Format(Date, "mm_dd_yy_hh") & ".xls"


    ActiveSheet.Copy
    ActiveSheet.SaveAs Filename:=fn
    ActiveWorkbook.Close
    Application.DisplayAlerts = True
    Application.ScreenUpdating = True

    End Sub

  6. #6
    Registered User
    Join Date
    10-28-2008
    Location
    Ohio
    Posts
    29
    Thanks for all the Help I solved the problem.

    Sub CopySave()

    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    Dim fn As String

    'copies form to the same directory
    fn = ThisWorkbook.Path & "\" & "Report " & Format(Now, "mm-dd-yy hhmm") & ".xls"


    ActiveSheet.Copy
    ActiveSheet.SaveAs Filename:=fn
    ActiveWorkbook.Close
    Application.DisplayAlerts = True
    Application.ScreenUpdating = True

    End Sub

+ 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