Simply put, I've tried following the example found here : How to add events to Controls created at runtime in Excel with VBA but when I click my button nothing happens.
The thing is that I don't create lots of buttons at once, a new button is added everytime the user clicks a certain pre added button.
Code for the button creation :
'Finally the delete button
Dim newb As MSForms.CommandButton
'thisQuant is a var keeping track of how many buttons there are
Set newb = FProducts.Controls.Add("Forms.CommandButton.1", "del" & thisQuant, False)
Dim Button As New Class1
Set Button.delButton = newb
And the new Class as stated in the example :
Public WithEvents delButton As MSForms.CommandButton
Private Sub delButton_Click()
MsgBox "test"
'quantProd = CInt(NewNota.ProductQuant.Caption)
End Sub
I come from python and VBA is extremely confusing.