#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 158
Default Command Button

Dear experts,

I want to create a command button and when I click it, rows under row 30
will be collapsed. When I click the button again, it toggles to expand the
rows under row 30. In the meantime, can the wording on the button be changed
to "expand rows" in collapse status and "collapse rows" in expand status? Is
it required a VBA code to operate? If yes, please kindly advise the code.

Thanks in advance
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 276
Default Command Button

Something lik:


Sub HideRows()
With Sheet1
Rows("30:65536").Select
Selection.EntireRow.Hidden = True
ActiveSheet.Shapes("CommandButton1").Select
Sheet1.CommandButton1.Caption = "Expand Rows"
End With
End Sub

Sub ShowRows()
With Sheet1
Rows("30:65536").Select
Selection.EntireRow.unHide = True
ActiveSheet.Shapes("CommandButton1").Select
Sheet1.CommandButton1.Caption = "Colapse Rows"
End With
End Sub



Corey....
"Freshman" wrote in message
...
Dear experts,

I want to create a command button and when I click it, rows under row 30
will be collapsed. When I click the button again, it toggles to expand the
rows under row 30. In the meantime, can the wording on the button be
changed
to "expand rows" in collapse status and "collapse rows" in expand status?
Is
it required a VBA code to operate? If yes, please kindly advise the code.

Thanks in advance



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 158
Default Command Button

Hi Corey,

Thanks for your tip and it works great. Thanks once again.

"Corey" wrote:

Something lik:


Sub HideRows()
With Sheet1
Rows("30:65536").Select
Selection.EntireRow.Hidden = True
ActiveSheet.Shapes("CommandButton1").Select
Sheet1.CommandButton1.Caption = "Expand Rows"
End With
End Sub

Sub ShowRows()
With Sheet1
Rows("30:65536").Select
Selection.EntireRow.unHide = True
ActiveSheet.Shapes("CommandButton1").Select
Sheet1.CommandButton1.Caption = "Colapse Rows"
End With
End Sub



Corey....
"Freshman" wrote in message
...
Dear experts,

I want to create a command button and when I click it, rows under row 30
will be collapsed. When I click the button again, it toggles to expand the
rows under row 30. In the meantime, can the wording on the button be
changed
to "expand rows" in collapse status and "collapse rows" in expand status?
Is
it required a VBA code to operate? If yes, please kindly advise the code.

Thanks in advance




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
Command Button Freshman Excel Worksheet Functions 6 June 1st 07 07:15 AM
command button wayno Excel Worksheet Functions 1 July 31st 06 02:02 AM
command button Zygan Excel Discussion (Misc queries) 0 June 30th 06 01:59 AM
Command button CEG Excel Discussion (Misc queries) 1 May 4th 06 09:54 PM
Command Button Chris Hale Excel Discussion (Misc queries) 1 February 10th 05 05:14 AM


All times are GMT +1. The time now is 09:55 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"