+ Reply to Thread
Results 1 to 2 of 2

Copy/Pasting a Sheet multiple times in the same work book

Hybrid View

  1. #1
    Registered User
    Join Date
    11-15-2014
    Location
    Perth, Australia
    MS-Off Ver
    2013
    Posts
    7

    Copy/Pasting a Sheet multiple times in the same work book

    Hi Everybody!

    I'm trying to copy and paste a single sheet multiple times in the same workbook. I've got some code based on the record macro feature and some help which I'm very grateful for through the forums so far but its not quite doing what I need it to.


    What the Macro is doing is good for the first copy (copying sheet1 and creating sheet2 exactly). When I run the macro again it creates sheet3 but copies in sheet2. I think I can see why (the command is telling it to paste in the active sheet) however I don't know how to change that.

    What I would like the macro to do eventually is to run when a value is put in cell AH1 of Airborne Fibre Estimation, copy the Sheet1 and paste (based on the column widths) up to the half the value of cell AH1 on Airborne Fibre Estimation, rounded up to next even number.

    The Macro

    
    Sub AFE_Dup()
    '
    ' AFE_Dup Macro
    ' Duplicate AFE Sheet1 format and formulas based on thevalue in cell AH1
    '
    ' Keyboard Shortcut: Ctrl+d
    '
        Cells.Select
        Selection.Copy
        Sheets.Add After:=Sheets(Sheets.Count)
        Application.CutCopyMode = False
        Application.PrintCommunication = False
        With ActiveSheet.PageSetup
            .PrintTitleRows = ""
            .PrintTitleColumns = ""
        End With
        Application.PrintCommunication = True
        ActiveSheet.PageSetup.PrintArea = ""
        Application.PrintCommunication = False
        With ActiveSheet.PageSetup
            .LeftHeader = ""
            .CenterHeader = ""
            .RightHeader = ""
            .LeftFooter = ""
            .CenterFooter = ""
            .RightFooter = ""
            .LeftMargin = Application.InchesToPoints(0.31496062992126)
            .RightMargin = Application.InchesToPoints(0)
            .TopMargin = Application.InchesToPoints(0.236220472440945)
            .BottomMargin = Application.InchesToPoints(0.236220472440945)
            .HeaderMargin = Application.InchesToPoints(0.31496062992126)
            .FooterMargin = Application.InchesToPoints(0.196850393700787)
            .PrintHeadings = False
            .PrintGridlines = False
            .PrintComments = xlPrintNoComments
            .PrintQuality = 600
            .CenterHorizontally = False
            .CenterVertically = False
            .Orientation = xlLandscape
            .Draft = False
            .PaperSize = xlPaperA4
            .FirstPageNumber = xlAutomatic
            .Order = xlDownThenOver
            .BlackAndWhite = False
            .Zoom = 100
            .PrintErrors = xlPrintErrorsDisplayed
            .OddAndEvenPagesHeaderFooter = False
            .DifferentFirstPageHeaderFooter = False
            .ScaleWithDocHeaderFooter = True
            .AlignMarginsHeaderFooter = True
            .EvenPage.LeftHeader.Text = ""
            .EvenPage.CenterHeader.Text = ""
            .EvenPage.RightHeader.Text = ""
            .EvenPage.LeftFooter.Text = ""
            .EvenPage.CenterFooter.Text = ""
            .EvenPage.RightFooter.Text = ""
            .FirstPage.LeftHeader.Text = ""
            .FirstPage.CenterHeader.Text = ""
            .FirstPage.RightHeader.Text = ""
            .FirstPage.LeftFooter.Text = ""
            .FirstPage.CenterFooter.Text = ""
            .FirstPage.RightFooter.Text = ""
        End With
        Application.PrintCommunication = True
        ActiveWindow.View = xlPageLayoutView
        Sheets("Sheet1").Select
        Cells.Select
        Selection.Copy
        Sheets("Sheet2").Select
        Range("A1").Select
        Selection.PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, _
            SkipBlanks:=False, Transpose:=False
        ActiveSheet.Paste
    End Sub
    If there is a solution you're willing to share that would be fantastic

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,486

    Re: Copy/Pasting a Sheet multiple times in the same work book

    Cells.Select
        Selection.Copy
        Sheets.Add After:=Sheets(Sheets.Count)
        Application.CutCopyMode = False
    You selected cells and copied, then added a worksheet. Then you turned CutCopy to false, so there is no longer anything to paste.
    You obviously want to copy the entire sheet to a new sheet, what was wrong with the code I gave you in your previous post?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Copy/Pasting an excel sheet with the same formatting/formulas in the same work book to x
    By Morallach in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-20-2014, 02:57 AM
  2. Copy active sheet to a new workbook, close that work book and return
    By nig_44 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-30-2012, 02:24 AM
  3. Excel 2007 : Copy and Pasting multiple times
    By Ray789 in forum Excel General
    Replies: 4
    Last Post: 05-05-2010, 02:40 PM
  4. Macro to copy sheet from closed work book and overwrite if sheet already exists
    By munkee in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 11-23-2009, 06:36 PM
  5. [SOLVED] Find and copy across multi-sheet work book
    By chris in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-30-2005, 03:05 PM

Tags for this Thread

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