Hi everyone,
I have added some buttons in a worksheet that hide certain rows if they are not necessary.
My issue is that if rows are added or removed from the Range that the code touches, then my code doesn't adjust itself which makes it irrelevant.
Is there a way that I could make it so the rows indicated in the code are tied to a start and end point so my table is hidden and shown as desired?
Here is my code :
Private Sub ToggleButton1_Click()
Dim xAddress As String
xAddress = "58:64"
If ToggleButton1.Value Then
Application.ActiveSheet.Rows(xAddress).Hidden = True
Else
Application.ActiveSheet.Rows(xAddress).Hidden = False
End If
End Sub
Picture of file as is when hidden :
Capture.PNG
Picture of file as is when not hidden :
Capture.PNG
Picture of file if rows are added and then the button is used to hide the table (2 rows were added at the center of the table) :
Capture.PNG
Bookmarks