If the cells are hidden, how do you propose to put something other than zero into them to unhide them? You may want to rethink this.
Thank you alansidman:
Cells are not empty, they have a formula and their value changes as per information is added or subtracted from other cells.
Private Sub Worksheet_Calculate()
Dim Cell As Range
On Error GoTo ErrHandler
'put your own cells here
For Each Cell In Range("C37:C38,C40:C45,A54:A58")
Application.ScreenUpdating = False
Application.EnableEvents = False
ThisWorkbook.Sheets("Name of Your Worksheet").Unprotect
If Cell.Value > 0 Then
Cell.EntireRow.Hidden = False
Else
Cell.EntireRow.Hidden = True
End If
Next
ErrHandler:
Application.ScreenUpdating = True
Application.EnableEvents = True
ThisWorkbook.Sheets("Name of Your Worksheet").Protect
End Sub
Try this:
Code:Private Sub Worksheet_Calculate() Dim Cell As Range On Error GoTo ErrHandler 'put your own cells here For Each Cell In Range("C37:C38,C40:C45,A54:A58") Application.ScreenUpdating = False Application.EnableEvents = False ThisWorkbook.Sheets("Name of Your Worksheet").Unprotect If Cell.Value > 0 Then Cell.EntireRow.Hidden = False Else Cell.EntireRow.Hidden = True End If Next ErrHandler: Application.ScreenUpdating = True Application.EnableEvents = True ThisWorkbook.Sheets("Name of Your Worksheet").Protect End Sub