Macro to hide rows based on criteria
Try this
Sub stantial()
Dim myrange, hiderange As Range
Lastrow = Cells(Cells.Rows.Count, "C").End(xlUp).Row
Set myrange = Range("C1:C" & Lastrow)
For Each c In myrange
If c.Value < "" And c.Offset(, 4) = 0 And c.Offset(, 5) = 0 _
And c.Offset(, 4) < "" And c.Offset(, 5) < "" Then
If hiderange Is Nothing Then
Set hiderange = c.EntireRow
Else
Set hiderange = Union(hiderange, c.EntireRow)
End If
End If
Next
If Not hiderange Is Nothing Then
hiderange.EntireRow.Hidden = True
End If
End Sub
Mike
"Santa-D" wrote:
I am in the process of doing end of year financial reporting analysis
and I want to be able to run a macro that hides empty rows based on a
specific criteria.
Column C lists the accounts codes, column G is the YTD Actuals and
column H is the YTD Budget.
What I want to do, is.....
If there is a value in a row in Column C and if the value of the cell
in both column G & H is 0 the hide the row.
If anyone can point me in the right direction to research this further
would be sincerely appreciated.
PS: I am using MS Excel 2003
|