Macro to Hide/Unhide rows based on a True/False cell value

Graesen

New Member
Joined
Jun 6, 2015
Messages
4
Hi. I'm hoping that someone out there with macro skills can help me out.

I'm creating an Excel based form and would like to be able to hide/unhide rows of worksheet based on a cell value. For example, if the value of cell A1 = True then I would like to see rows 5 to 10. If the value = False then I would like to hide rows 5 to 10.

I hope this makes sense.
All responses will be be gratefully received

Thanks
G.
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Try this code
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Range("a1").Value = True Then
    Rows("5:10").EntireRow.Hidden = True
    Else
    Rows("5:10").EntireRow.Hidden = False
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,829
Messages
6,121,827
Members
449,051
Latest member
excelquestion515

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top