I have a worksheet where I have manually hidden some rows if the value if column A (A1, a2, a3, etc) =0. Now I have created two buttons with assigned macros so I can unhide these rows or hide the rows. The code is below and it works fine.
Sub Unhide()
Rows(“5:30”).EntireRow.Hidden = False
End Sub
Sub hide()
Dim i As Integer
Application.ScreenUpdating = False
For i = 5 To 30
If Sheets(“planning”).Range(“A” & i).Value = “0” Then
Rows(i).EntireRow.Hidden = True
End If
Next i
Application.ScreenUpdating = True
End Sub
——
I would like to be able to combine both of these actions into the same button as a toggle which would mean changing the assigned macro or running code based on the value of a flag as well as changing the text of that button depending on the value of that flag – something like click to unhide or click to hide.
However, I don’t know how to do this. Any advice or ideas?