Copying button with sheet help

jstacy

New Member
Joined
Dec 27, 2017
Messages
11
I have a template sheet that I need to copy 1 button on the template sheet to the new sheet. I am using the following code to copy the sheet; can someone assist with the code need to copy the button (Button 2) as well in this code?

Code:
Sub Duplicate_Sheet()    Dim wsName As Variant
    With ThisWorkbook
        .Worksheets("BOM Template").Copy After:=.Worksheets("BOM Template")
    End With
    wsName = InputBox("Enter Part #" & vbCrLf & "Example: SagePart# (Drawing #)", "New sheet")
    If wsName <> "" Then
        With ActiveSheet
            .Name = wsName
            .Visible = True
            ActiveSheet.[C4] = ActiveSheet.Name
        End With
    End If
    With Range("F5")
.Value = Date
.NumberFormat = "mm-dd-yy"
End With
End Sub
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
When I use your script all the buttons are copied to the new sheet. Are you saying you only want to copy button named "Button2"? And all the data but not other buttons.


I have a template sheet that I need to copy 1 button on the template sheet to the new sheet. I am using the following code to copy the sheet; can someone assist with the code need to copy the button (Button 2) as well in this code?

Code:
Sub Duplicate_Sheet()    Dim wsName As Variant
    With ThisWorkbook
        .Worksheets("BOM Template").Copy After:=.Worksheets("BOM Template")
    End With
    wsName = InputBox("Enter Part #" & vbCrLf & "Example: SagePart# (Drawing #)", "New sheet")
    If wsName <> "" Then
        With ActiveSheet
            .Name = wsName
            .Visible = True
            ActiveSheet.[C4] = ActiveSheet.Name
        End With
    End If
    With Range("F5")
.Value = Date
.NumberFormat = "mm-dd-yy"
End With
End Sub
 
Last edited:
Upvote 0
When I use your script all the buttons are copied to the new sheet. Are you saying you only want to copy button named "Button2"? And all the data but not other buttons.

That is different then my result, none of the buttons copy over to the new sheet. I only want the one button but I am not getting any, only the sheet template itself.
 
Upvote 0
What type button is this? Is this a shape or a activex control type button. What is the exact name of the button?

Put button name in quotes like this "Button 1"

Are you using A Apple Computer?
What version of Excel?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,562
Messages
6,131,422
Members
449,651
Latest member
Jacobs22

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