Module 1 code Which includes:
Macros are enabled.
This runs fine when the all of the code is in Module1.
When I Move the Sub Test() subroutine into the sheet that has the button added, it errors when I click the button, "Cannot run the macro ... "The macro may not be available in this workbook or all macros may be disabled."
It longer sees the 'Sub Test()' for some reason.
Is there a way to prefix the name of the subroutine so that the button will see it in the sheet that the button is located in, or does the subroutine HAVE to be in a module?
VBA Code:
Sub CreateAClickableMacroButton()
... Some Code
MacroToRunWhenButtonIsClicked = "Test" ' <--- Set this to the name of the macro that you want to run when button is clicked
... Some Code
.OnAction = MacroToRunWhenButtonIsClicked ' Subroutine to run when button is clicked
... Some Code
End Sub
Sub Test()
MsgBox "You clicked the button"
End Sub
Macros are enabled.
This runs fine when the all of the code is in Module1.
When I Move the Sub Test() subroutine into the sheet that has the button added, it errors when I click the button, "Cannot run the macro ... "The macro may not be available in this workbook or all macros may be disabled."
It longer sees the 'Sub Test()' for some reason.
Is there a way to prefix the name of the subroutine so that the button will see it in the sheet that the button is located in, or does the subroutine HAVE to be in a module?