Is there a way to pass the ActiveSheet object and an object as arguments to a sub that is called by a Command Button on a worksheet?
I know you can pass arguments to a macro from a command button from the following:
How to call a macro from a button and pass arguments
However how would you send the following arguments to a sub when Button_1 is clicked? (without using a commandButton_click event)
argument 1: ws as worksheet (the worksheet that contains the button that was pressed) argument 2: button as object (the button that was pressed)
I've tried the following in the "Assign Macro" input box for the button.
'SubToBeCalledByButton(ActiveSheet, this)'
Tried /u/Nathan_Sav suggestion to put call like: 'SubToBeCalledByButton(activesheet, activesheet.shapes("Button Name"))' but got the following error:
Here is input I used in assign macro:
Here is the sub being called by the button:
Public Sub DetailButton(ws As Excel.Worksheet, but As Object)
Debug.Print "ws:" & vbTab & ws.Name
Debug.Print "but:" & vbTab & but.Name
Debug.Print "cal:" & vbTab & Application.Caller
End Sub