Tom has attended:
Excel VBA Intro Intermediate course
Access Intermediate course
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
RE: Button to hide/show rows
Hi Tom
Thanks 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