Macro to hide rows based on a zero value in a particular cell

P

Peter

How complicated is it to create a macro to hide rows
conditioned upon a zero value in a particular column of
that row? Could a second condition also be added to test
for bold font type zeros to not be hidden? I have a VERY
large cost estimating spreadsheet with 2,000 rows of
items, and want to be able to hide rows that do not
apply. Summary rows are in bold type and I would like to
retain them, but hide all the detail. It takes forever
manually!.
 
D

David Adamson

Just adopted something from the group. Sorry can't remember name



'make cells dispapear
Sub Button1_Click()
Dim cell As Range
Application.ScreenUpdating = False
For Each cell In Range("A1:A60")

If cell.Font.Bold = False Then
If cell.Value = 0 Then
cell.EntireRow.Hidden = True
ElseIf cell.Value <> 0 Then
cell.EntireRow.Hidden = False
End If
End If
Next
Application.ScreenUpdating = True

End Sub

'make all cells reappear
Sub Button2_Click()
Dim cell As Range

For Each cell In Range("A1:A60")
cell.EntireRow.Hidden = False
Next
Application.ScreenUpdating = True

End Sub
 
N

Norman Jones

Hi Peter,

Have a look at "Outline a worksheet " and at "Group Ungroup" in help. This
feature could very well do exactly what you want and would enable you to
click between various hierarchical data levels revealing or hiding support
data.



Also, look to use the AutoFilter and Advanced Filters.
 

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

Top