Macro to show only rows with X

  • Thread starter Thread starter Jeremy
  • Start date Start date
J

Jeremy

How would I write a script or macro to display rows that have and x in "A"
and hide all other rows?


Thank you
 
Option Explicit
Sub Remove_Unwanted_Rows()
Dim rng As Range
Dim cell, RowArray As Range
Set rng = ActiveSheet.Range(Cells(1, "A"), Cells(Rows.Count, "A").End(xlUp))
For Each cell In rng
Select Case cell
Case Is <> "x"
If RowArray Is Nothing Then
Set RowArray = cell.EntireRow
Else
Set RowArray = Union(RowArray, cell.EntireRow)
End If
End Select
Next cell
On Error Resume Next
RowArray.EntireRow.Hidden = True
Err.Clear
End Sub
 
Back
Top