I've been trying to get the ID of a dynamically created button on a function which is called when any of the dynamic buttons is clicked.
The program is pretty simple, is a checkout for an ice cream store, the buttons get their values from a list of products on a Sheet, the only thing that I need is to get the name of the button to get the index in which is located, so I can read the products properties (such as price)
I am currently using a UserForm, which I modified from this post, but basically does the same:
Assign code to a button created dynamically
I also tried with dynamic buttons on a Sheet, but couldn't get to run the function, It is supposed to run with the following:
Set btn = Sheet1.Buttons.Add(t.Left, t.Top, t.Width, t.Height)
With btn
.OnAction = "Button_Click"
.Caption = Product(idx)
.Name = Product(idx) & " " & i
End With
And I'm pretty sure that this would work within the "Button_Click" Sub
Application.Caller
Any help would be much appreciated, although I'd rather use an UserForm, since it looks better
PS. I don't want to hide/show buttons to solve this issue, that would become a potential limit on the number of items that can be read, and also, every item would be kind of permanently fixed