You don't state which cell contains your IF statement, so the following example uses A1 as the cell containing the function. Also, you don't specify the rows you wish to 'toggle' as visible/hidden. This example uses rows 2:5, and 9.
If your cell is not A1 and your rows not 2:5, and 9, modify the code before copying:
Change the two "A1" references to your cell reference, i.e. "C12", "M25", etc.
Change the two "2:5" references to your actual rows to hide. You can use the following types of range references:
One contiguous range: Range("A5:A20")
Individual cells: Range("A1,A4,A5,A12")
A non-contiguous Range: Range("A2:A9,A22,A26,A40:A55")
Modify to suit your needs.
Then, copy the event handler to the clipboard (highlight the entire code, right click inside the highlighted area, and 'Copy'):
Private Sub Worksheet_Change(ByVal Target As Range)
If UCase(Range("A1").Value) = "YES" Then
Range("A2:A5,A9").EntireRow.Hidden = False
ElseIf UCase(Range("A1").Value) = "NO" Then
Range("A2:A5,A9").EntireRow.Hidden = True
End If
End Sub
Select the worksheet containing the IF statement and right click the sheet tab at the bottom.
Select 'View Code'.
Paste the event handler into the white editing area to the right (right click inside the area and 'Paste').
Close the VBE (red button w/white 'x' - top right).
As the IF function returns the Yes/No values, the rows specified will be alternately hidden/visible.