Functions can only return values, not make formatting changes.
Is the value in O5 the result of a formula in O5?
Change event code is not triggered by a formula-generated value being changed.
Only triggered when you actually Enter something in the cell.
Try this if a formula-generated value in O5
Private Sub Worksheet_Calculate()
On Error GoTo endit
Application.EnableEvents = False
With Me.Range("O5")
If (.Value) = 0 Then
.EntireRow.Hidden = True
Else: .EntireRow.Hidden = False
End If
End With
endit:
Application.EnableEvents = True
End Sub
This is sheet event code. Right-click on your sheet tab and "View Code".
Copy/paste into that sheet module.
Gord Dibben MS Excel MVP