On vba, I'd like to add a button and assign to it a function with a parameter.
That's code to the create the button (in module1):
Set testBtn = Worksheets("HOME").Buttons.Add(Position.Left, Position.Top, Position.Width * 2, Position.Height * 2)
With testBtn
.OnAction = Send_click(ActiveSheet.Name)
.Caption = "LOAD " & ActiveSheet.Name
.Name = "LOAD " & ActiveSheet.Name
.Font.Bold = True
End With
while the function to call is defined in another module as:
Function Send_click(sheetName As String)
However, the button appears as not clickable and a macro LOADxxx_click appears as assigned (where xxx is the name of the ActiveSheet.name) but it clearly doesn't exist.
I have also tried suggestions I found here and also to specify the module:
.OnAction = Module4.Send_click(ActiveSheet.Name)
with no different results.