+ Reply to Thread
Results 1 to 7 of 7

Copy entire worksheet including all Macros and VBA Code

  1. #1
    Registered User
    Join Date
    12-15-2008
    Location
    hanover
    Posts
    34

    Copy entire worksheet including all Macros and VBA Code

    I am sure this is simple, but I don't know how to do it.
    I need to copy my worskheet multiple times to create about 10 of the same worksheets within a workbook. I know if you click in the very most top left hand corner of the worksheet, then click copy, go to the new worksheet and click paste, it copies the whole page, but it does not copy over the VBA Code. Also, for some reason, it does copy over my macro buttons, but does not put some of them in the right spot?

    Any help on this would be greatly appreciated
    Last edited by VBA Noob; 12-16-2008 at 04:08 PM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Try
    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    12-15-2008
    Location
    hanover
    Posts
    34

    Red face

    I'm sorry, but I am a real ammateur at this VBA stuff. So where would I post the code that you recommended? In each of the sheets that I want to have the first worksheet copied into? How do you trigger the code? Would I put the code in exactly as you had typed it?

    Thanks for trying to help me out. I appreciate your time.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    The code goes in a code module.

    1. Copy the code from the post
    2. Press Alt+F11 to open the Visual Basic Editor (VBE)
    3. From the menu bar in the VBE window, do Insert > Module
    4. Paste the code in the window that opens
    5. Close the VBE to return to Excel

    Then do Alt+F8 from Excel, scroll down and select the macro copySht, and press Run.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Registered User
    Join Date
    12-15-2008
    Location
    hanover
    Posts
    34

    Question

    So do I post this code in the sheets that I am trying to copy to or from?

    Thanks for walking me through this.

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    A virgin workbook has two kinds of modules: One ThisWorkbook module, and a Sheet module for each sheet. Those modules are special in that they support processing of workbook and sheet events.

    To that, you can add any number of Code modules. Code modules are not associated with any particular sheet. This code goes in a code module.

  7. #7
    Registered User
    Join Date
    12-15-2008
    Location
    hanover
    Posts
    34

    Smile Solved

    Thank you so much for your help with this and for taking the time to explain the VBA language to me. I really appreciate your time.
    Could you please mark this thread as SOLVED.

+ 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