Toggle hide macro

  • Thread starter Thread starter Robert Hustead
  • Start date Start date
R

Robert Hustead

Hello & thanks for the many fine tips!

I am looking for a macro that I will assign to a button(I know how to
insert the button and assign the macro). I am trying to toggle
hide/unhide all rows with cells in column "G" that display "0", or are
empty. I was also wondering...if these cells contain formulas such as
=A9+C9, which equal "0", if this formula would prevent the toggle hide
macro from working?

Thank you for any advise with this macro!
 
Sub togglerows()
Dim rng As Range
Dim cell As Range
Set rng = Intersect(ActiveSheet.UsedRange, Columns(7))
For Each cell In rng
If cell.Text = "0" Or cell.Text = "" Then
cell.EntireRow.Hidden = Not cell.EntireRow.Hidden
Else
cell.EntireRow.Hidden = False
End If
Next

End Sub
 
Back
Top