+ Reply to Thread
Results 1 to 3 of 3

Copy, paste & save worksheet many times

  1. #1
    Registered User
    Join Date
    04-19-2012
    Location
    Ireland
    MS-Off Ver
    Excel 2003
    Posts
    20

    Copy, paste & save worksheet many times

    Hi All, long time no chat, delighted to be back and thanks for being there.
    I have a macro (recorded in stages) that copies a worksheet from one WB (name “Test Module” ) into another workbook (name “Test Summary”).
    I need to copy it a minimum of 4 times (possibly 6) and save each copy on a different sheet in "Test Summary".
    Can you advise what additional code I need and where do I place it. Also I’d like to rename the new sheets in "Test Summary" to show the year e.g. 2015_1, 2015_2 etc.
    Here’s my code It’s very long (and likely very inefficient). Hope that makes sense and Thanks again.


    Sub CopySave_test()
    '
    ' CopySave_test Macro
    ' Macro recorded 14-07-2015 by Me3
    '

    ' From Original Workbook "Test Module”with Summary sheet open, unprotect & Copy
    ActiveSheet.Unprotect
    Range("A1:H39").Select
    Selection.Copy

    'open specific workbook "Test_Summary" and paste copied info into sheet1, then copy sheet1 in new workbook & paste special, pasteValues. (to remove links)
    ChDir "C:\Users\Me3\Documents\John\Bernadette"
    Workbooks.Open Filename:= _
    "C:\Users\Me3\Documents\John\ Bernadette\Test_Summary.xls"
    Range("A1").Select
    ActiveSheet.Paste
    Range("A1:H39").Select
    Application.CutCopyMode = False
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    ‘Set column widths
    Range("B1:G1").Select
    Selection.ColumnWidth = 14
    Range("A1").Select
    Selection.ColumnWidth = 30

    'set page to Landscape
    With ActiveSheet.pagesetup
    .PrintTitleRows = ""
    .PrintTitleColumns = ""
    End With
    ActiveSheet.pagesetup.PrintArea = "$A$1:$H$39"

    With ActiveSheet.pagesetup
    .PrintTitleRows = ""
    .PrintTitleColumns = ""
    End With
    ActiveSheet.pagesetup.PrintArea = "$A$1:$H$39"
    With ActiveSheet.pagesetup
    .LeftHeader = ""
    .CenterHeader = ""
    .RightHeader = ""
    .LeftFooter = ""
    .CenterFooter = ""
    .RightFooter = ""
    .LeftMargin = Application.InchesToPoints(0.590551181102362)
    .RightMargin = Application.InchesToPoints(0.590551181102362)
    .TopMargin = Application.InchesToPoints(0.393700787401575)
    .BottomMargin = Application.InchesToPoints(0.511811023622047)
    .HeaderMargin = Application.InchesToPoints(0.393700787401575)
    .FooterMargin = Application.InchesToPoints(0.511811023622047)
    .PrintHeadings = False
    .PrintGridlines = True
    .PrintComments = xlPrintNoComments
    .PrintQuality = 300
    .CenterHorizontally = False
    .CenterVertically = False
    .Orientation = xlLandscape
    .Draft = False
    .PaperSize = xlPaperA4
    .FirstPageNumber = xlAutomatic
    .Order = xlDownThenOver
    .BlackAndWhite = False
    .Zoom = 85
    .PrintErrors = xlPrintErrorsDisplayed
    End With

    'Still in Test_Summary WB, view "pagebreak preview" and set parameters for one page print
    With ActiveSheet.Select
    ActiveWindow.View = xlPageBreakPreview
    Application.CutCopyMode = False
    ActiveSheet.pagesetup.PrintArea = "$A$1:$H$39"
    ActiveWindow.View = xlNormalView
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
    ActiveSheet.EnableSelection = xlUnlockedCells
    End With
    With ActiveWorkbook.ActiveSheet
    ActiveWorkbook.Save
    ActiveWindow.Close

    'Original Workbook is now active
    Range("A1").Select
    ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
    End With

    End Sub

  2. #2
    Valued Forum Contributor quekbc's Avatar
    Join Date
    01-18-2010
    Location
    Sydney, Australia
    MS-Off Ver
    2010, 2013, 2016
    Posts
    1,149

    Re: Copy, paste & save worksheet many times

    Firstly, please use the
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    04-19-2012
    Location
    Ireland
    MS-Off Ver
    Excel 2003
    Posts
    20

    Re: Copy, paste & save worksheet many times

    Thank you quekbc,
    apologies re code, formatting.

    Also apologies again, as from my understanding of your answer (I'm not an expert) my question was really not as clear as I thought and certainly didn't explain what I'm trying to achieve.
    With my very limited understanding of code, I interpret your answer as setting the pasted sheet as active and then pasting it 4 times using the for/next loop with a facility to rename each sheet.
    And apologies one more time as I don't understand what this code does
    Please Login or Register  to view this content.
    What I am looking for is the original sheet to be copied and pasted once. Then when original sheet has been added to over a period, I copy it again and paste it in the same work book in addition to the one pasted earlier, using a different sheet name, thereby keeping a record of each copying action.

    Regards
    D

    When I say "the original sheet to be copied and pasted once." I mean pasted in a new workbook.
    Last edited by d.i.y. man; 07-15-2015 at 10:12 AM. Reason: I didn't mention a second workbook in myresponse

+ 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. Replies: 0
    Last Post: 01-29-2014, 07:38 AM
  2. [SOLVED] Copy/Paste a row x times
    By Choppo in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-14-2013, 10:20 AM
  3. Macro that can save a worksheet multiple times
    By glide2131 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-15-2013, 08:00 PM
  4. MACRO - Paste value and then save file multiple times ---- please help
    By aetedford in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-10-2013, 08:53 PM
  5. copy and paste in one-go instead of performing 20 times copy & paste?
    By cyli2423 in forum PowerPoint Formatting & General
    Replies: 1
    Last Post: 08-24-2012, 06:06 AM
  6. Copy and paste data from a worksheet to template, save it with a name and location.
    By sumplacenwa in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-28-2012, 12:47 AM
  7. Copy paste not working after save of worksheet
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-14-2005, 02:15 AM
  8. [SOLVED] Worksheet Buttons (Save, Save As, Cut, Paste, etc.) Not Working
    By SuzieQ12345 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-21-2005, 11:06 AM

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