Use string variable to set object variable in VBA? (Excel 2013)
I have a number of ActiveX controls/buttons on a page, and I would like to modify several of the parameters of the buttons (in a loop function). I am fine with writing the loop function to achieve this, but cannot find a way to refer to the object using a string variable. I have set up an object variable (as per below), and a string variable to be used to change the reference for the object variable - but can't find a way to get it to work. This is the code that does NOT work: Private Sub TrialCode_Click() Dim ButtonObj As Object Dim ButtonCaption As String Dim ButtonString As String