PC Review


Reply
Thread Tools Rate Thread

after autofilter/delete rows left not visible

 
 
John Keith
Guest
Posts: n/a
 
      13th Jan 2009
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.Delete

Range("A1").Select
ActiveSheet.AutoFilterMode = False
Range("A2").Select
Application.ScreenUpdating = True

John Keith
(E-Mail Removed)
 
Reply With Quote
 
 
 
 
Don Guillett
Guest
Posts: n/a
 
      13th Jan 2009
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
(E-Mail Removed)
"John Keith" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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.Delete
>
> Range("A1").Select
> ActiveSheet.AutoFilterMode = False
> Range("A2").Select
> Application.ScreenUpdating = True
>
> John Keith
> (E-Mail Removed)


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Print Only Visible Rows Using AutoFilter RyanH Microsoft Excel Programming 3 20th Oct 2008 06:15 PM
Excel copy only visible rows from autofilter duketter Microsoft Excel Misc 2 30th Jun 2008 10:55 PM
countif for only visible rows when combined with autofilter - possible? johli Microsoft Excel Misc 1 21st Sep 2005 08:23 AM
AutoFilter: Loop Thru Visible Rows? =?Utf-8?B?RGFtaWFuIENhcnJpbGxv?= Microsoft Excel Programming 2 21st Jul 2005 01:16 AM
AutoFilter - which rows are currently visible? Bjørnar Hartviksen Microsoft Excel Programming 2 6th Oct 2003 12:01 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:35 AM.