Display row if cell = value

Occasional Contributor

How do I display or hide a row if a cell = a certain value? A real basic example:

EK_Blackwell_0-1657894752791.png

Show row 7 if I7 = REQUIRED

I'm trying if statements but not sure if the result is Hide/Unhide. Other suggestions are Unconditional Formatting and Filter, but I'm not getting it right.

I know it's a newbie question and thanks for helping. I'm running Excel 365. 

 

 

1 Reply

@EK_Blackwell 

Sub hide_unhide()

Dim i As Long

For i = 5 To 26

If Cells(i, 9).Value = "Required" Then
Rows(i).EntireRow.Hidden = True

Else
End If

Next i

End Sub

You can try these lines of code. In the attached file you can click the button in cell F2 to run the macro. In order to unhide the rows change line 8 of the code to:

Rows(i).EntireRow.Hidden = False