Hello,
I'm trying to create a macro (M1) where I copy everything from one sheet (A) to another sheet (B). In sheet A there are a number of buttons that have macros assigned to them. When copying all data from A to B, the buttons are also copied. For the copied buttons to work in sheet B, they need to be assigned to a macro (M2) specific for that sheet (B), and this action is also included in the macro (M1).
When I record the macro (M1) everything works fine, but when I try running the macro (M1), it looks very strange and it does not work.
I've attached the code for the complete macro (M1) and highlighted where it appears to go wrong.
Sub Copy_Budget_to_Forecast_2()
'
' Copy_Budget_to_Forecast_2 Macro
'
'
Sheets("Forecast (w. planning)").Select
ActiveSheet.Shapes.Range(Array("myButton1")).Select
Selection.Delete
ActiveSheet.Shapes.Range(Array("myButton2")).Select
ActiveWindow.SmallScroll Down:=11
ActiveSheet.Shapes.Range(Array("myButton2", "myButton3")).Select
ActiveWindow.SmallScroll Down:=20
ActiveSheet.Shapes.Range(Array("myButton2", "myButton3", "mybutton4")). _
Select
ActiveWindow.SmallScroll Down:=10
ActiveSheet.Shapes.Range(Array("myButton2", "myButton3", "mybutton4", _
"mybutton5")).Select
ActiveWindow.SmallScroll Down:=6
ActiveSheet.Shapes.Range(Array("myButton2", "myButton3", "mybutton4", _
"mybutton5", "mybutton6")).Select
ActiveWindow.SmallScroll Down:=-2
Selection.Delete
ActiveWindow.SmallScroll Down:=-1
ActiveWindow.LargeScroll Down:=-1
ActiveWindow.SmallScroll Down:=-20
Sheets("Budget (w. plan)").Select
Range("A8:DE150").Select
Selection.Copy
Sheets("Forecast (w. planning)").Select
Range("A8").Select
ActiveSheet.Buttons.Add(272.25, 145.5, 63.75, 21).Select
ActiveSheet.Buttons.Add(272.25, 366.75, 63.75, 21).Select
ActiveSheet.Buttons.Add(272.25, 573.75, 63.75, 21).Select
ActiveSheet.Buttons.Add(272.25, 779.25, 63.75, 21).Select
ActiveSheet.Buttons.Add(272.25, 955.5, 63.75, 21).Select
ActiveSheet.Buttons.Add(272.25, 1103.25, 63.75, 21).Select
ActiveSheet.Paste
Range("A7").Select
ActiveSheet.Shapes.Range(Array("myButton1")).Select
Application.CutCopyMode = False
Selection.OnAction = "Sheet5.InsertRowByButton"
ActiveSheet.Shapes.Range(Array("myButton2")).Select
Selection.OnAction = "Sheet5.InsertRowByButton"
ActiveWindow.SmallScroll Down:=16
ActiveSheet.Shapes.Range(Array("myButton3")).Select
Selection.OnAction = "Sheet5.InsertRowByButton"
ActiveWindow.SmallScroll Down:=19
ActiveSheet.Shapes.Range(Array("mybutton4")).Select
Selection.OnAction = "Sheet5.InsertRowByButton"
ActiveWindow.SmallScroll Down:=10
ActiveSheet.Shapes.Range(Array("mybutton5")).Select
Selection.OnAction = "Sheet5.InsertRowByButton"
ActiveWindow.SmallScroll Down:=5
ActiveSheet.Shapes.Range(Array("mybutton6")).Select
ActiveWindow.LargeScroll Down:=-3
Range("A7").Select
End Sub
Can anyone help me to see why it goes wrong?
Bookmarks