View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Leith Ross[_507_] Leith Ross[_507_] is offline
external usenet poster
 
Posts: 1
Default How do I hide 5 command buttons


Hello Neil,

Since you didn't say which type of Command Buttons you have Forms or
Control Toolbox type I am including macro examples for both.
________________________________

Example 1 - Hide/Unhide Forms Type:
Sub HideCommandButtons()
With Worksheets("New Style 2006")
..Shapes("Button 1").Visible = False
..Shapes("Button 2").Visible = False
..Shapes("Button 3").Visible = False
..Shapes("Button 4").Visible = False
..Shapes("Button 5").Visible = False
End With
End Sub

Sub UnHideCommandButtons()
With Worksheets("New Style 2006")
..Shapes("Button 1").Visible = True
..Shapes("Button 2").Visible = True
..Shapes("Button 3").Visible = True
..Shapes("Button 4").Visible = True
..Shapes("Button 5").Visible = True
End With
End Sub


Example 2 - Hide/Unhide Controls Toolbox Type:
Sub HideCommandButtons()
Dim Button As Object
With Worksheets("New Style 2006")
Set Button = .OLEObjects("CommandButton1")
Button.Visible = False
Set Button = .OLEObjects("CommandButton2")
Button.Visible = False
Set Button = .OLEObjects("CommandButton3")
Button.Visible = False
Set Button = .OLEObjects("CommandButton4")
Button.Visible = False
Set Button = .OLEObjects("CommandButton5")
Button.Visible = False
End With
End Sub

Sub UnHideCommandButtons()
Dim Button As Object
With Worksheets("New Style 2006")
Set Button = .OLEObjects("CommandButton1")
Button.Visible = True
Set Button = .OLEObjects("CommandButton2")
Button.Visible = True
Set Button = .OLEObjects("CommandButton3")
Button.Visible = True
Set Button = .OLEObjects("CommandButton4")
Button.Visible = True
Set Button = .OLEObjects("CommandButton5")
Button.Visible = True
End With
End Sub
________________________________

Remember to change the command button names to match the names on your
worksheet.

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=506161