Archive of Mr Excel Message Board


Back to Controls in Excel archive index
Back to archive home

commandbuttons collection?

Posted by John on August 17, 2001 12:55 PM
Hey folks-

I have a worksheet which has rather a lot of commandbuttons on it, and I would like to make them either visible or invisible depending on the user's selection. Unfortunately, I cannot think of a way of doing this short of individually refering to each button...
commandbutton365000.visible = false
commandbutton365001.visible = false, etc.

OK so it's not this bad, but I do have almost 200 buttons (and please don't ask why, it made sense at the time)

If this was on a form, I could just use the controls collection, but this doesn't appear to apply to worksheets. Is there some collection that applies to the commandbuttons so that I could write code like:

For each my_button in commandbuttons
my_button.visible = false
next my_button

Any advice offered would be greatly appreciated.
Thanks in advance

-John


Re: commandbuttons collection?

Posted by Robb on August 17, 2001 6:32 PM
John

Try this:

For Each sh In Worksheets("SheetName").Shapes
sh.Visible = True
Next sh


Any help?

Regards


Bingo! Thanks Robb

Posted by John on August 20, 2001 6:16 AM
Like the heading says, "Bingo! Thanks Robb"

This archive is from the original message board at www.MrExcel.com.
All contents © 1998-2004 MrExcel.com.
Visit our online store to buy searchable CD's with thousands of VBA and Excel answers.
Microsoft Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.