Results 1 to 5 of 5

Command to 'overwrite' existing sheet

Threaded View

  1. #1
    Forum Contributor
    Join Date
    07-15-2011
    Location
    Whitby, Canada
    MS-Off Ver
    Excel 2010
    Posts
    121

    Command to 'overwrite' existing sheet

    Hi all,

    I have a macro I am running to pull reports from 2 different sheets and pasting to a new sheet:

    Sub STAT2011()
    
    Worksheets.Add().Name = "STAT-2011"
    Sheets("Nov 2011").Activate
        Sheets("Nov 2011").Columns("A:B").Copy Destination:=Sheets("STAT-2011").Columns("A:B")
    
    Sheets("Nov 2011").Columns("G").Copy Destination:=Sheets("STAT-2011").Columns("C")
        Sheets("STAT-2011").Columns("C").Value = Sheets("Nov 2011").Columns("G").Value
    
    Sheets("Dec 2011").Columns("G").Copy Destination:=Sheets("STAT-2011").Columns("D")
        Sheets("STAT-2011").Columns("D").Value = Sheets("Dec 2011").Columns("G").Value
        Sheets("Annual 2011").Columns("G").Copy Destination:=Sheets("STAT-2011").Columns("E")
        Sheets("STAT-2011").Columns("E").Value = Sheets("Annual 2011").Columns("G").Value
    
    
    Sheets("STAT-2011").Activate
    End Sub
    What I want to include is a command at the beginning of the code so that even though there is already a sheet called "STAT-2011" (created the month prior) the macro will 'overwrite' that sheet and create the new one?....

    TIA
    Last edited by Greed; 12-14-2011 at 12:56 PM.

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