This will toggle hide/unhide:
Sub HideToggle()
If Rows("3:5").EntireRow.Hidden = True Then
Rows("3:5").EntireRow.Hidden = False
Else
Rows("3:5").EntireRow.Hidden = True
End If
End Sub
Thanks for the reply. I am still having some problems. Here is my code:
The first sub is for the button, which should allow the user to click and the HideToggle to be activated. However, when I run the VB (as in when I push the "play" button to run the code) it hides the rows straight-away, and then when I click the button that should show the button, I get the error "Run-Time error '1004': Unable to set the hidden property of the range class." Any ideas? Thanks again!
Private Sub CommandButton1_Click()
HideToggle
End Sub
Sub HideToggle()
If Rows("3:5").EntireRow.Hidden = True Then
Rows("3:5").EntireRow.Hidden = False
Else
Rows("3:5").EntireRow.Hidden = True
End If
End Sub
Just assign HideToggle() to your button and remove
the call. I could not repeat your error.
Sorry to seem so inept when it comes to this stuff, but how do I assign HideToggle() to the button. What's the code? I just started programming in Excel this week. Thank you so much for your help!
Could you copy and paste the code you're using? Just to back-up here, to run the code I just click the "play" button, right? Okay, thanks again.
Paste the code into a module like you did before.
Create the button and assign the HideToggle().
Or right click an existing button and assign
HideToggle().
Okay, so I put the HideToggle code into a new module. How do I assign it to the button? I feel like an idiot, because I'm sure it's obvious, but I think I'm missing something here. Thanks much.