How do I get my controls to copy with my worksheet?

krice1974

Active Member
Joined
Jul 3, 2008
Messages
422
Hey all. I've written a method to copy a worksheet that contains a couple of command buttons at the top of it. The sheet is copied fine, but the command buttons and a text box at the top of the sheet won't copy. I experimented with adding a dummy sheet and button, and recording copying them. I see that the add button is grabbed in the macro, but not when I record copying my sheet of interest. Any ideas? Here's the code:

Code:
Sub NewAccountManagerSheet(SheetName As String, AccountManager As String, Area As String)
    
    Dim shName As String
    
    shName = SheetName & "-MA" ' "for manager area."
    
    Sheets("AccountManagerTemplate").Unprotect
    Sheets("AccountManagerTemplate").Copy Before:=Sheets(2)
    Sheets("AccountManagerTemplate (2)").Name = shName
    Sheets(shName).Range("AccountManager") = AccountManager
    Sheets(shName).Range("Area") = Area
    Sheets(shName).Activate
    Sheets(shName).Protect DrawingObjects:=False, Contents:=True, Scenarios:=False
    
End Sub
 
Last edited:

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Are you sure that the objects aren't being copied? This worked for me:

Code:
ActiveSheet.Copy Before:=Sheets(2)
 
Upvote 0
I wouldn't lie to ya. :) The code above doesn't copy the buttons on the sheet "AccountManagerTemplate."
 
Upvote 0
Well I've never known that to happen. In fact I just tested your code as below and it worked as expected (Excel 2010):

Code:
Sub Test()
    Call NewAccountManagerSheet("NewSheet", "Andrew", "Derby")
End Sub

Are you sure that your code is referencing the correct workbook?
 
Upvote 0
Well I've never known that to happen. In fact I just tested your code as below and it worked as expected (Excel 2010):

Code:
Sub Test()
    Call NewAccountManagerSheet("NewSheet", "Andrew", "Derby")
End Sub

Are you sure that your code is referencing the correct workbook?

It is. When I copy the sheet with click and drag, it isn't copying them then, either.
 
Upvote 0
Thanks for the help, Andrew. Excel just crashed, and upon restarting, it is now copying the buttons properly. :) All is well that ends well..
 
Upvote 0
In Excel Options in the Advanced section is a setting to Cut, Copy and Sort inserted objects with their parent cells. If that's unchecked, then they don't get copied with the sheet.
 
Upvote 0

Forum statistics

Threads
1,216,073
Messages
6,128,644
Members
449,461
Latest member
kokoanutt

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top