VBA: Automatically Hide/Unhide Rows Based on Cell Values

khom97

New Member
Joined
Jul 2, 2018
Messages
1
I am attempting to make it so rows hide/unhide based on the values in Cells C6, C12, and C14. I wrote the code for it and had it working, but for some reason after coming back to it a few days later it no longer works. The code is as follows:

Code:
Private Sub WorkSheet_Change(ByVal target As Range)
        
    If ThisWorkbook.Worksheets("Part Selector").Range("C14") = "Yes" And ThisWorkbook.Worksheets("Part Selector").Range("C6") = "800A" And ThisWorkbook.Worksheets("Part Selector").Range("C12") = "Main Breaker Switchboard" Then
        Me.rows("16:18").EntireRow.Hidden = False

    Else        
        Me.rows("16:18").EntireRow.Hidden = True

    End If

End Sub
I'm relatively new, so I don't know if there is an issue with the syntax. My biggest confusion is why the code worked earlier and no longer does. Any help is greatly appreciated!
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
This works for me:
Code:
Private Sub WorkSheet_Change(ByVal target As Range)
    If Intersect(target, Range("C6,C14,C12")) Is Nothing Then Exit Sub
    If Range("C14") = "Yes" And Range("C6") = "800A" And Range("C12") = "Main Breaker Switchboard" Then
        Rows("16:18").EntireRow.Hidden = False
    Else
        Rows("16:18").EntireRow.Hidden = True
    End If
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,756
Messages
6,132,533
Members
449,733
Latest member
Nameless_

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