A client requested that I add the buttons as shown in image 1 below.
There can be from 1 to 100 sets of buttons. The reason is unimportant to this question.
Seeing as they have practically identical functions I need to assign them but somehow have the row number available as a parameter or variable or something.
Private Sub Edit_CVR_Row(Btn_row As Integer)
At the generation of the buttons the row number is part of a for loop and known and this is how I assign the macro
With btn
.OnAction = "'Edit_CVR_Row """ & Btn_row & "'"
.Caption = "Edit"
.Name = "Sheet1_" Str(Btn_row) "_Edit"
End With
This is the error I get
There is a similar solution that uses the Evaluate function with similar results.
Any help will be greatly appreciated.
CodePudding user response:
When you open your Excel file, is there a yellowish band on top of your cells asking you to activate the macros ? If so, you should accept it before running your macro, otherwise you will receive that kind of notification.
It is also possible that macros are not activated in your Excel, you can check it by going in the File tab --> Options --> Trust center --> Macro setting, and then you will have to select the option you want.
CodePudding user response:
activesheet.buttons(application.caller).topleftcell.row
Thank you for this Rory, it worked.