PDA

View Full Version : [SOLVED] How do I create a macro that allows me to show and hide rows with only one button?



Davespil
07-18-2016, 07:24 AM
Hello, I would like to be able to click a button and unhide 10 rows. Then click the same button and have them hide those rows. I have the macro to unhide the rows, I just don't know how to make the same button hide them if they aren't hidden. Can anyone help me with that. My understanding of VBA is extremely limited. Thank you in advance. Here is my macro so far:


Sub MultiYear_Show()
'
' MultiYear_Show Macro
'
'
Rows("10:20").Select
Selection.EntireRow.Hidden = False
End Sub

JKwan
07-18-2016, 07:57 AM
give this a go


Rows("10:20").EntireRow.Hidden = Not Rows("10:20").EntireRow.Hidden

Davespil
07-18-2016, 08:22 AM
give this a go


Rows("10:20").EntireRow.Hidden = Not Rows("10:20").EntireRow.Hidden


It worked! Thank you.