Toggle Macro . . .

  • Thread starter Thread starter Fable
  • Start date Start date
F

Fable

Greetings,

Is it possible to create a toggle macro (in the same code), for exampl
I have one Macro button on my sheet where the user would press once an
it would hide rows 5-10 and if the user presses the same button agai
it would show rows 5-10. Any thoughts?

Thanks
 
Fable, here is one way
Sub Toggle_Rows()
With ActiveSheet
If Rows("5:10").EntireRow.Hidden = True Then
Rows("5:10").EntireRow.Hidden = False
Else
Rows("5:10").EntireRow.Hidden = True
End If
End With
End Sub


--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2000 & 2003
** remove news from my email address to reply by email **
 
With Rows("5:10")
If .EntireRow.Hidden Then
.EntireRow.Hidden = False
Else
.EntireRow.Hidden = True
End If
End With
 
or

Sub togglehide()
Rows("5:10").EntireRow.Hidden = True = Not _
Rows("5:10").EntireRow.Hidden = True
End Sub

--
Don Guillett
SalesAid Software
(e-mail address removed)
Paul B said:
Fable, here is one way
Sub Toggle_Rows()
With ActiveSheet
If Rows("5:10").EntireRow.Hidden = True Then
Rows("5:10").EntireRow.Hidden = False
Else
Rows("5:10").EntireRow.Hidden = True
End If
End With
End Sub


--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2000 & 2003
** remove news from my email address to reply by email **
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top