+ Reply to Thread
Results 1 to 5 of 5

How to Copy a Master worksheet that contains Buttons with Macros Assigned

Hybrid View

  1. #1
    Registered User
    Join Date
    08-04-2013
    Location
    Liverpool, England
    MS-Off Ver
    Excel 2010
    Posts
    5

    How to Copy a Master worksheet that contains Buttons with Macros Assigned

    Hey Guys / Girls

    I am creating a spreadsheet that will have a master worksheet.

    On my home page their will be a button that once clicked will copy the master sheet and paste it as a new worksheet at the end renaming the sheet "New Employee".

    All that is fine and easy done but what is not is that the master has three navigation / Save buttons on and once this copies, the Buttons on the Master sheet revert to "Button(number)" and have no macro assigned.

    How can i change this?

    Regards

    Ian

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: How to Copy a Master worksheet that contains Buttons with Macros Assigned

    If you are using Form-type buttons and use the Worksheet.Copy method to copy the sheet, it could work.

    Show your code that copies the Master sheet and what type of buttons are you using?
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    08-04-2013
    Location
    Liverpool, England
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: How to Copy a Master worksheet that contains Buttons with Macros Assigned

    AlphaFrog, my code is below. I think it might have something to do with the Buttons.Add lines but im not quite sure, only do the basics

    Cheers

    Sub Create_New_Employee()
    '
    ' Create_New_Employee Macro
    '

    '
    Sheets("Master").Select
    ActiveSheet.Buttons.Add(5.25, 6.75, 261.75, 33.75).Select
    ActiveSheet.Buttons.Add(446.25, 4.5, 261.75, 33.75).Select
    ActiveSheet.Buttons.Add(285, 4.5, 141.75, 33.75).Select
    Sheets("Master").Copy After:=Sheets(2)
    Sheets("Master (2)").Select
    Sheets("Master (2)").Name = "New Employee"
    Range("D5").Select
    End Sub
    Last edited by iblac_788; 08-04-2013 at 03:25 PM.

  4. #4
    Valued Forum Contributor
    Join Date
    05-20-2013
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2013
    Posts
    941

    Re: How to Copy a Master worksheet that contains Buttons with Macros Assigned

    In your code, after creating the copy and naming it, try inserting...

    Sheets("New Employee").Shapes.SelectAll
    Selection.Delete
    Of course this assumes you no longer want the buttons. Otherwise one method is to retrieve button names and reassign their respective macros.
    Last edited by jhren; 08-04-2013 at 03:00 PM.

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: How to Copy a Master worksheet that contains Buttons with Macros Assigned

    If the Master Sheet already has the Buttons with assigned macros, this will copy the sheet with the buttons.

    Sub Create_New_Employee()
    '
    ' Create_New_Employee Macro
    '
        Sheets("Master").Copy After:=Sheets(Sheets(Sheets.Count))
        ActiveSheet.Name = "New Employee"
        Range("D5").Select
    End Sub

+ 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] How to use macros to open hidden tabs from a master worksheet?
    By Jon Gray in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-17-2013, 03:30 PM
  2. Replies: 0
    Last Post: 11-06-2012, 05:31 PM
  3. Replies: 0
    Last Post: 06-25-2012, 04:40 AM
  4. Name of macros assigned to buttons changes
    By lestercrombie in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-16-2005, 01:47 AM
  5. Replies: 4
    Last Post: 05-15-2005, 07:07 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