+ Reply to Thread
Results 1 to 2 of 2

Need to copy all the contents of a worksheet into a new workbook

Hybrid View

  1. #1
    Registered User
    Join Date
    07-13-2012
    Location
    U.S.A.
    MS-Off Ver
    Excel 2010
    Posts
    3

    Need to copy all the contents of a worksheet into a new workbook

    Hello. I am a completely new to vba. I was given a worksheet with multiple scenario macros. After each macro, I'd like lines of code to copy all the contents of that worksheet into a sheet named after each scenario.

    So, after the first scenario1 code is run, the contents of the sheet for scenario1 is copied to a NEW sheet (would have to create the sheet) scenario1output. Scenario2 code is run, contents are copied into scenario2output sheet.

    Ideally it would look to see if there is already a scenario1output or scenario2output sheet before creating a new one, but if that's getting complicated, that's okay...

    Any help would be appreciated!

    What I've got so far that keeps crashing...

    Sub Macro2()
    '
    ' Macro2 Macro
    '
    ' Keyboard Shortcut: Ctrl+Shift+Q
    '
        Sheets.Add After:=Sheets(Sheets.Count)
        Sheets("Sheet27").Select
        Sheets("Sheet27").Name = "Scenario2output"
        Application.Goto Reference:="Sheet1!RC"
        Selection.Copy
        Cells.Select
        Application.CutCopyMode = False
        Selection.Copy
        Application.Goto Reference:="Scenario2output!RC"
        ActiveSheet.Paste
    End Sub
    Last edited by Cutter; 07-24-2012 at 06:58 PM. Reason: Added code tags

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,935

    Re: Need to copy all the contents of a worksheet into a new workbook

    Thanks for the code tags.
    Where are you keeping the scenario names? How do you know which one is run?
    Last edited by protonLeah; 07-24-2012 at 10:49 PM.
    Ben Van Johnson

+ 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