Hiding rows based on cell content

  • Thread starter Thread starter alistair01
  • Start date Start date
A

alistair01

I am looking to hide a row in a worksheet where the column o contain
the value false.This sounds easy but just cant get my head round it
 
try this simple code:

Option Explicit
Sub test()
delete_row Selection
End Sub


Sub delete_row(target As Range)

If target.Value = "False" Then
Rows(target.Row).Delete
End If

End Sub


Patrick Molloy
Microsoft Excel MVP
 
A possible modification

Option Explicit
Sub test()
Dim rw As Range
With ActiveSheet
For Each rw In Intersect(.Columns("O"), .UsedRange)
Hide_row rw
Next
End With
End Sub


Sub Hide_row(target As Range)
If Not IsEmpty(target) Then
If target.Value = False Then
Rows(target.Row).EntireRow.Hidden = True
Else
Rows(target.Row).EntireRow.Hidden = False
End If
End If
End Sub
 
Back
Top