Hide and unhide rows based on cell value on another sheet

lawrebw

New Member
Joined
Feb 7, 2019
Messages
4
I have two sheets, Sheet1 and Sheet2

If F8 value in Sheet 1 is "No", then rows 39 to 43 in sheet 2 should hide

I currently have the following code on Sheet1

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("F8")) Is Nothing Then
If Target.Value = "No" Then
Worksheets("Sheet2").Rows("39:43").Hidden = True
End If
End If
End Sub

It will hide the rows when "No" is selected in a pull down for cell F8, however when "Yes" is selected it does not unhide the rows.


Any assistance would be greatly appreciated. Thanks!
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Use the following:

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("F8")) Is Nothing Then
        If Target.Value = "No" Then
            Worksheets("Sheet2").Rows("39:43").Hidden = True
        ElseIf Target.Value = "Yes" Then
            Worksheets("Sheet2").Rows("39:43").Hidden = False
        End If
    End If
End Sub
 
Upvote 0
I'm glad to help you. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,203,094
Messages
6,053,504
Members
444,667
Latest member
KWR21

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