Hide Row Based on cell value

G

GaryF

What may I do to automatically hide all rows whos first
cell has the value "NA"?
Thank you,
gary
 
B

Bob Phillips

Hi Gary,

Here is one way

Sub CopyMe()
Dim sToFind As String
Dim clastrow As Long
Dim myRange As Range

With ActiveSheet
clastrow = .Cells(Rows.Count, "A").End(xlUp).Row
.Range("A1").EntireRow.Insert
sToFind = "NA"
.Columns("A:A").AutoFilter Field:=1, Criteria1:=sToFind
Set myRange = .Rows("2:" & clastrow +
1).SpecialCells(xlCellTypeVisible).Rows
.Range("A1").EntireRow.Delete
End With
myRange.Hidden = True

End Sub



--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
G

Gary Fuller

Thank you Bob.
Gary
-----Original Message-----
Hi Gary,

Here is one way

Sub CopyMe()
Dim sToFind As String
Dim clastrow As Long
Dim myRange As Range

With ActiveSheet
clastrow = .Cells(Rows.Count, "A").End(xlUp).Row
.Range("A1").EntireRow.Insert
sToFind = "NA"
.Columns("A:A").AutoFilter Field:=1, Criteria1:=sToFind
Set myRange = .Rows("2:" & clastrow +
1).SpecialCells(xlCellTypeVisible).Rows
.Range("A1").EntireRow.Delete
End With
myRange.Hidden = True

End Sub



--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)




.
 
B

Bob Phillips

A pleasure Gary.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Top