I would like to have a piece of code that runs when any worksheet commandbutton is pressed. I have seen similar things for userforms but can't find something that works across (and limited to) worksheet buttons.
I have got as far as creating a class module called clsCmdButton with the following code:
Private WithEvents cmdButton As MSForms.CommandButton
Private Sub cmdButton_Click()
'code i want to run
End Sub
I then think I need to loop through all worksheets, find the commandbuttons on it and intialise each as a new insance of the class. This could be done in the Workbook_Open event, however I am not sure how to code it. Could anyone help?
Thanks!