Referencing command button on worksheet from VBA

  • Thread starter Thread starter Ken Warthen
  • Start date Start date
K

Ken Warthen

I have several command buttons on a worksheet in an Excel 2007 workbook. I
have a login form that hides/shows worksheets based on the login name of
either Administrator or User. If the login is User I also want to change the
visible property of some of the command buttons to false. I'm having trouble
figuring out how to reference the command buttons on the worksheet from the
VBA module of the login form. Any help or direction would be greatly
appreciated.

Ken
 
Activesheet.Shapes("CommandButton1").Visible = false

where you replace CommandButton1 with the actual names. works whether they
came from the controls or the forms toolbar
 
Might be worth adding - if you're not activating the sheets as you loop
through them, it seems you have to refer to them by name as opposed to using
their indexes.
 
Thanks for the help.

slarbie said:
Might be worth adding - if you're not activating the sheets as you loop
through them, it seems you have to refer to them by name as opposed to using
their indexes.
 
Back
Top