View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Hide rows with value of 0

Hi,

Try this as worksheet code

Sub stantial()
Dim MyRange, CopyRange As Range
Lastrow = Cells(Cells.Rows.Count, "N").End(xlUp).Row
Set MyRange = Range("N1:N" & Lastrow)
For Each c In MyRange
If Not IsEmpty(c) And c.Value = 0 And Not _
IsEmpty(c.Offset(, 4)) And c.Offset(, 4).Value = 0 Then
If CopyRange Is Nothing Then
Set CopyRange = c.EntireRow
Else
Set CopyRange = Union(CopyRange, c.EntireRow)
End If
End If
Next
If Not CopyRange Is Nothing Then
CopyRange.EntireRow.Hidden = True
End If
End Sub

Mike

"chrismv48" wrote:

Hello,

This is a fairly common question relating to hiding rows, but mine comes
with a bit of a twist.

I get a monthly spreadsheet that is generated to have a formatting that
hides a lot of particular rows to begin with. This precludes me from using
filters. In addition to the rows already hidden, I'd like to hide the rows
that contain a 0 in both columns N & R.

Ideally I'd like to be able to run this macro on a selection, but all
suggestions are welcome.

Thanks.