Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Button to hide/show rows
Button to hide/show rows
Resolved · Low Priority · Version 2007
Button to hide/show rows
Hi,I am looking to create a button that hides certain rows at the first click and then shows them again on the next click, I thought this would do it (partly taken from a recorded macro) but it only hides the rows and then does nothing. Thanks very much...
Sub Hide_Previous_Working_Week()
' Hides the previous working week table
If Rows("30:53").Hidden Then
Rows("30:53").Select
Selection.EntireRow.Hidden = False
Else
Rows("31:52").Select
Selection.EntireRow.Hidden = True
End If
End Sub
For upcoming training course dates see: Pricing & availability
RE: Button to hide/show rows
Hi TomThanks for your question
Your problem was that when the rows were hidden, you were trying to select them, and this was causing problems. Fortunately, this is not necessary.
I have rewritten the code thus:
Sub Hide_Previous_Working_Week()
' Hides the previous working week table
If Rows("30:53").Hidden Then
Rows("30:53").EntireRow.Hidden = False
Else
Rows("30:53").EntireRow.Hidden = True
End If
End Sub and it now works
Regards
Stephen
RE: Button to hide/show rows
Thats brilliant thank you very much for your time.Tom
|
|
» Forum post: Visio - Centre of Rotation - Resetting |



Course updates

