Referencing command button on worksheet from VBA

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
 
S

slarbie

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

where you replace CommandButton1 with the actual names. works whether they
came from the controls or the forms toolbar
 
S

slarbie

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.
 
K

Ken Warthen

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top