I have the VBA code in an Excel 2013 worksheet to hide two rows (B8:B9) when B7 selection is set to 'Pass'. That part works.
ClearContents
closes Excel without any reason.
I want to clear those cell contents before/after the rows are hidden or unhidden.
Private Sub Worksheet_Change(ByVal Target As Range)
If Range("B7").Value <> "Pass" Then
Range("B8:B9").ClearContents
Rows("8:9").EntireRow.Hidden = True
Else
Rows("8:9").EntireRow.Hidden = False
End If
End Sub
The B8:B9 cells are Data Validation List.