Hiding rows with zero values


Tim Hackney

Other than by manual selection, is there a function or
macro that can hide all rows in a spreadsheet if a cell in
a particular column is zero. I know this can be done, but
don't know how!



Frank Kabel

Hi Tim
have try the following (looks in column D for a zero):
Sub hide_rows()
Dim RowNdx As Long
Dim LastRow As Long

LastRow = ActiveSheet.Cells(Rows.Count, "D").End(xlUp).row
For RowNdx = LastRow To 1 Step -1
If Cells(RowNdx, "D").Value = 0 Then
Rows(RowNdx).hidden = True
End If
Next RowNdx
End Sub



Ken Wright

One way is with Autofilter. Select your range of data and do Data / Filter /
Autofilter - Then click on the dropdown and choose greater than 0.

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question