I have an odd issue with a single command button refusing to run the macro attached. I get the message "Cannot run the macro "". The macro may not be available in this workbook or all macros may be disabled."
I have three buttons created by code on a new sheet and the macros assigned. The first two buttons work perfectly but the third does not. If I re-assign the same macro to the button (right click - assign macro) it works fine but this will not accomplish what I need.
All macros etc have been enabled. I hope someone can help, this is doing my head in!
Sub AddButton()
Dim ButtonName1, ButtonName2, ButtonName3 As String
ActiveSheet.Buttons.Add(200, 5, 81, 36).Select
ButtonName1 = Selection.Name
Selection.OnAction = "CopyBack"
ActiveSheet.Shapes(ButtonName1).TextFrame.Characters.Text = "Modify Scenario (Copy back)"
ActiveSheet.Buttons.Add(285, 5, 81, 36).Select
ButtonName2 = Selection.Name
Selection.OnAction = "GotoPlanner"
ActiveSheet.Shapes(ButtonName2).TextFrame.Characters.Text = "Return To Shift Planner"
ActiveSheet.Buttons.Add(370, 5, 81, 36).Select
ButtonName3 = Selection.Name
Selection.OnAction = "DellCurrSheet"
ActiveSheet.Shapes(ButtonName3).TextFrame.Characters.Text = "Delete This Scenario"
ActiveSheet.Range("A1").Select
End Sub
抱歉,如果我在此上浪费了任何人的时间,但是我发现了造成宏名称分配问题的错字。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.