Re: Variable as button name
Hi,
You can access ActiveX controls on sheet using OLEObjects collection:
Code:
Dim strButtonName As String
strButtonName = "cmdButton2"
Sheets(1).OLEObjects(strButtonName).Object.BackColor = vbRed
If you command button is placed on form you can use Controls collection:
Code:
Dim strButtonName As String
strButtonName = "cmdButton1"
Me.Controls(strButtonName).BackColor = vbBlue
Hope this helps.
Regards,
Sebastian
Re: Variable as button name
Thanks you very much Sebastian.
It works well.