How to Fix: Copying Worksheet breaks Button (Form Control) Links and Custom Name

willow1985

Well-known Member
Joined
Jul 24, 2019
Messages
888
Office Version
  1. 365
Platform
  1. Windows
Hello,

I have a Macro that makes a copy of the current sheet I am on, however every time it does it breaks 2 of my Form Control Buttons on the Sheet that are linked to Macros.

Is there any way to prevent this?

VBA Code:
Sub VIEW_DD()
'
' VIEW_DD Macro
'

'
Application.DisplayAlerts = False
Application.CopyObjectsWithCells = False
    Sheets("Demand Detail").Select
    ActiveSheet.Buttons.Add(4.5, 3.75, 81.75, 36).Select
    ActiveSheet.Buttons.Add(90.75, 3.75, 62.25, 36).Select
    ActiveSheet.Shapes.Range(Array("Year 1")).Select
    ActiveSheet.Shapes.Range(Array("Flag 1")).Select
    ActiveSheet.Shapes.Range(Array("Flag without Date")).Select
    ActiveSheet.Shapes.Range(Array("Order Type")).Select
    ActiveSheet.Shapes.Range(Array("Column1")).Select
    Sheets("Demand Detail").Copy
    Windows("Master Forecast Inc.xlsm").Activate
   
    Application.DisplayAlerts = True
    Application.CopyObjectsWithCells = True

End Sub

Thank you to anyone who can help :)
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
I figured it out. I had to remove the following 2 lines:

VBA Code:
   ActiveSheet.Buttons.Add(4.5, 3.75, 81.75, 36).Select
    ActiveSheet.Buttons.Add(90.75, 3.75, 62.25, 36).Select
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,862
Members
449,052
Latest member
Fuddy_Duddy

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