Thread
:
after autofilter/delete rows left not visible
View Single Post
#
2
Posted to microsoft.public.excel.programming
Don Guillett
external usenet poster
Posts: 10,124
after autofilter/delete rows left not visible
Try this. I corrected for word wrap on the code lines
Sub filterit()
On Error Resume Next
lr = Cells.Find("*", Cells(Rows.Count, Columns.Count) _
, , , xlByRows, xlPrevious).Row
Range("a1:c" & lr).AutoFilter Field:=2, _
Criteria1:="<2005"
Range("a2:c" & lr).SpecialCells _
(xlCellTypeVisible).EntireRow.Delete
Range("a1:c" & lr).AutoFilter
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software
"John Keith" wrote in message
...
I am using an autofilter to select rows that I want to delete, then
delete them, I then turn off the autofilter and select cell A2 and
enable screenupdating. But at the end of executing this code row A2 is
not visible, rather a row much lower (608 actually) is visible in the
window. How do I get row A2 to be visible in the window?
Dim rTable As Range
Range("A1").Select
With Selection
If .Cells.Count 1 Then
Set rTable = Selection
Else
Set rTable = .CurrentRegion
On Error GoTo 0
End If
End With
Range("A2").Select
ActiveSheet.AutoFilterMode = False
' Delete all rows that are NOT for year 2005
rTable.AutoFilter Field:=2, Criteria1:="<*"2005"*",
Operator:=xlAnd
rTable.Offset(1,
0).SpecialCells(xlCellTypeVisible).EntireRow.Delet e
Range("A1").Select
ActiveSheet.AutoFilterMode = False
Range("A2").Select
Application.ScreenUpdating = True
John Keith
Reply With Quote
Don Guillett
View Public Profile
Find all posts by Don Guillett