Hiding Rows

  • Thread starter Thread starter Lloyd H. London
  • Start date Start date
L

Lloyd H. London

Can anyone give me some guidance to set up a macro to look at a series
of cells in a single column, and check the contents of each cell. If
the contents are not empty, hide the entire row.
I would also need to reverse it eventually...such as unhide all rows in
current sheet.

Any help will be appreciated.
 
Try this:
Sub HideIfContents()
On Error Resume Next
'uses column of active cell

Columns(ActiveCell.Column).SpecialCells(xlCellTypeConstants).EntireRow.Hidde
n = True

Columns(ActiveCell.Column).SpecialCells(xlCellTypeFormulas).EntireRow.Hidden
= True
End Sub

Sub Unhide()
Cells.EntireRow.Hidden = False
End Sub

Bob Umlas
Excel MVP
 
Works almost perfectly. One problem I didnt anticipate.
Row 1 has field headers that I would prefer not to be hidden. Can the
first row be left unhidden?
 
Instead of code, could you use Data|Filter|autofilter?

In fact, if you need code, you could record a macro when you used
data|filter|autofilter.
 
Back
Top