Results 1 to 4 of 4

VBA code problem copying saving workbook

Threaded View

  1. #1
    Registered User
    Join Date
    10-05-2012
    Location
    Gainsborough, England
    MS-Off Ver
    Office 2016 & Office 365
    Posts
    87

    VBA code problem copying saving workbook

    Hi
    Great forum, I am very new to Excel let alone VBA, below is a piece of code I have been workeng on, sure most can see what it does, click the command button it then makes a copy of the workbook into a different location and clears the contents of cells, What i am struggling with is..I want it to clear the contents in the original workbook not the new saved one, so in other words the backup copy keeps the data and the original clears ready for another time....sorry if this is stupid or wrong, maybe easy to some...I am i making any sense???


    Private Sub CommandButton13_Click()
    Dim nom As String
        nom = Day(Date) & "-" & Month(Date) & "-" & Year(Date) & "_" & ActiveWorkbook.Name
        ActiveWorkbook.SaveAs Filename:="C:Backup\" & nom
        Range("A7:Q20").ClearContents
        rep = MsgBox("Copied and Saved to Location X Have a Nice Day : ")
    End Sub
    Last edited by jet2004uk; 10-10-2012 at 09:46 AM. Reason: Added code tags for new users

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