Hello, I'm looking to hide and unhide rows on a sheet based on input values on a specific cell, including blanks. I don't have any experience in using Codes and tried a couple from other posts here that didn't quite match what I needed. I'm using excel to gather survey information so there are multiple rows/sections that I want to hide when someone chooses N within the main header row.
I'm using data validation allowing these options to be selected (blank/Y/N), when blank and N are chosen I need rows to be hidden but when Y is chosen I need the rows to unhide. There are 11 main headers that people will be required to say Y/N on or leave blank.
I tried using this below:
But the problem with this was every time i changed C4, regardless of what it was changed to, the rows would hide then unhide. I only want to see the rows when C4 displays as Y and not see the rows when C4 is blank or N. I'll need to use this all along the sheet for C23, C40, C56, C68, C90, C110, C122, C131, C139, C151 with the rows in between those locations hidden/unhidden based on their selection.
All help is very much appreciated!
I'm using data validation allowing these options to be selected (blank/Y/N), when blank and N are chosen I need rows to be hidden but when Y is chosen I need the rows to unhide. There are 11 main headers that people will be required to say Y/N on or leave blank.
I tried using this below:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
' Code goes in the Worksheet specific module
Dim rng As Range
' Set Target Range, i.e. Range("A1, B2, C3"), or Range("A1:B3")
Set rng = Target.Parent.Range("C4")
' Only look at single cell changes
If Target.Count > 1 Then Exit Sub
' Only look at that range
If Intersect(Target, rng) Is Nothing Then Exit Sub
' Action if Condition(s) are met (do your thing here...)
Rows("5:23").Hidden = Not Rows("5:23").Hidden
End Sub
But the problem with this was every time i changed C4, regardless of what it was changed to, the rows would hide then unhide. I only want to see the rows when C4 displays as Y and not see the rows when C4 is blank or N. I'll need to use this all along the sheet for C23, C40, C56, C68, C90, C110, C122, C131, C139, C151 with the rows in between those locations hidden/unhidden based on their selection.
All help is very much appreciated!