I have a sheet where I am already using a macro (tied to a button) to hide all of the rows in a range that contain 0. I'd also like to be able to hide the "header" row if all cells in that range are 0. If one or more cells is greater than 0 the header row should be shown.
Header row: 18, Range of cells C19:C174, header row 175 range of cells C176:C194, header row 195 range of cells C196:C220.
I haven't been able to find any solutions that address this problem specifically (maybe I'm searching for the wrong thing.
My code for hiding rows is below, maybe I can integrate the 2?
Header row: 18, Range of cells C19:C174, header row 175 range of cells C176:C194, header row 195 range of cells C196:C220.
I haven't been able to find any solutions that address this problem specifically (maybe I'm searching for the wrong thing.
My code for hiding rows is below, maybe I can integrate the 2?
VBA Code:
Sub HideRows()
Dim cell As Range, HideRow As Boolean
With ThisWorkbook.Sheets("QUICK QUOTE")
For Each cell In .Range("C19:C174,C176:C194,C196:C220,E240:E242").Cells
With cell
If IsNumeric(.Value) Then
If .Value = 0 Then HideRow = True ' flag to hide
End If
If Not .EntireRow.Hidden = HideRow Then ' take action
.EntireRow.Hidden = HideRow
End If
HideRow = False ' reset for the next iteration
End With
Next cell
End With
End Sub