Command Button

  • Thread starter Thread starter Freshman
  • Start date Start date
F

Freshman

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
 
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....
 
Back
Top