PDA

View Full Version : Solved: Hide Row based on particular word



agnesz
08-28-2009, 10:54 AM
Hi there
I need to be able to hide a row based on a row included in column H. If any cell in column H contains the word "comp" it shoudl be hidden. The word comp will always be preceded by other text. Attached file has a sample showing which rows should be hidden (highlighted in yellow).

Can anyone help?

Bob Phillips
08-28-2009, 11:11 AM
Dim rng As Range
Dim LastRow As Long

With ActiveSheet

LastRow = .Cells(.Rows.Count, "H").End(xlUp).Row
Set rng = .Range("H4").Resize(LastRow - 3)
rng.AutoFilter Field:=1, Criteria1:="=*comp*", Operator:=xlAnd
Set rng = rng.Offset(1, 0).SpecialCells(xlCellTypeVisible)
.Range("H4").AutoFilter
rng.EntireRow.Hidden = True
End With

agnesz
09-01-2009, 02:41 PM
perfecto!
thanks so much