MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Macro to ride rows


Posted by Jeff C. on January 15, 2002 9:36 AM

Can anyone help me out with a Macro that will hide an entire row of data if the value in a specific column of that row is = to zero? I have done this before, but I can't remember the code - Sorry I'm a rookie.

PS - Needs to be a macro - there is no other way

Thanks,
Jeff


Posted by DK on January 15, 2002 10:24 AM


Hello Jeff,

Here's one way. It's not the quickest but it's fairly simple and it's quick enough as long as you're not talking about thousands of rows.

HTH,
D.

Sub HideRows()
Dim lngRow As Long
'Turn off screen updating to increase macro speed
Application.ScreenUpdating = False
For lngRow = 1 To ActiveSheet.UsedRange.Rows.Count
If Range("A" & lngRow) = 0 Then Range("A" & lngRow).EntireRow.Hidden = True
Next
Application.ScreenUpdating = True
End Sub