Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default How do I hide 5 command buttons

Is there an easy way to hide / unhide 5 command buttons I have on one
worksheet named 'New Style 2006'

Rgds
Neil



  #2   Report Post  
Posted to microsoft.public.excel.programming
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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default How do I hide 5 command buttons

you could use something like this

Option Explicit
Dim i As Integer
Sub HideButtons()
Dim shp As String
With Worksheets("New Style 2006")
For i = 1 To 5
shp = "button " & i
Shapes(shp).Visible = False
Next
End With
End Sub

--


Gary


"Karoo News" wrote in message
...
Is there an easy way to hide / unhide 5 command buttons I have on one
worksheet named 'New Style 2006'

Rgds
Neil




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How do I hide 5 command buttons

Sub ABC()
Dim Obj As OLEObject
For Each Obj In ActiveSheet.OLEObjects
If TypeOf Obj.Object Is MSForms.CommandButton Then
Obj.Visible = Not Obj.Visible
End If
Next
End Sub

--
Regards,
Tom Ogilvy


"Karoo News" wrote in message
...
Is there an easy way to hide / unhide 5 command buttons I have on one
worksheet named 'New Style 2006'

Rgds
Neil





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How do I hide 5 command buttons

Here is the code with the New Style 2006 sheet specified.

Sub ABC()
Dim Obj As OLEObject
For Each Obj In Worksheets( _
"New Style 2006").OLEObjects
If TypeOf Obj.Object Is MSForms.CommandButton Then
Obj.Visible = Not Obj.Visible
End If
Next
End Sub


--
regards,
Tom Ogilvy


"Karoo News" wrote in message
...
Is there an easy way to hide / unhide 5 command buttons I have on one
worksheet named 'New Style 2006'

Rgds
Neil







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default How do I hide 5 command buttons

Thanks Tom that works perfect :-)

PS thanks to Leith & Gary too

"Tom Ogilvy" wrote in message
...
Here is the code with the New Style 2006 sheet specified.

Sub ABC()
Dim Obj As OLEObject
For Each Obj In Worksheets( _
"New Style 2006").OLEObjects
If TypeOf Obj.Object Is MSForms.CommandButton Then
Obj.Visible = Not Obj.Visible
End If
Next
End Sub


--
regards,
Tom Ogilvy


"Karoo News" wrote in message
...
Is there an easy way to hide / unhide 5 command buttons I have on one
worksheet named 'New Style 2006'

Rgds
Neil








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Hide Form and Command Buttons until such condition is true? ash3154 Excel Discussion (Misc queries) 0 September 2nd 09 12:37 AM
pivot chart is it possible to hide individual field buttons? Layout Field buttons Matt Charts and Charting in Excel 0 August 27th 06 02:57 PM
Command buttons Jock W Excel Programming 1 February 22nd 05 12:35 PM
Command buttons Russell Stevenson Excel Programming 3 November 12th 03 02:57 AM
Control Buttons vs. Command Buttons Robert Gibson Excel Programming 1 October 13th 03 04:33 PM


All times are GMT +1. The time now is 11:23 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"