Hide Row Based on cell value

  • Thread starter Thread starter GaryF
  • Start date Start date
G

GaryF

What may I do to automatically hide all rows whos first
cell has the value "NA"?
Thank you,
gary
 
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)
 
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)




.
 
A pleasure Gary.

--

HTH

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

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

Back
Top