Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2007

Tip: Looking for answers? Try searching our database.

Will not copy to City-Panmure

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steved - 21 Jan 2007 20:36 GMT
Hello from Steved

I have no I'dea as to what I've not done.
The below will filter City but it will not copy into City - Panmure Sheet

Please explain to me what is reqiured for this to function Thankyou.

Sub Copy_With_AutoFilter_2()
   Dim WS1 As Worksheet
   Dim WS2 As Worksheet
   Dim rng1 As Range
   Dim rng2 As Range
   Dim Str As String
   Set WS1 = Sheets("Trip missed")
   Set WS2 = Sheets("City - Panmure")
   Set rng1 = WS1.Range("A1").CurrentRegion
   Str = "City"
   WS1.AutoFilterMode = False
   rng1.AutoFilter Field:=7, Criteria1:=Str
   With WS1.AutoFilter.Range
       On Error Resume Next
       Set rng2 = .Offset(1, 0).Resize(.Rows.Count - 1, .Columns.Count) _
                  .SpecialCells(xlCellTypeVisible)
       On Error GoTo 0
       If Not rng2 Is Nothing Then
           rng2.Copy WS2.Range("A" & LastRow(WS2) + 1)
       End If
   End With
   WS1.AutoFilterMode = False
End Sub
Tom Ogilvy - 21 Jan 2007 21:08 GMT
Only problem I would see is if you don't get any visible rows when you
filter on City.

The code worked fine for me with some actual rows to copy.

Signature

Regards,
Tom Ogilvy

> Hello from Steved
>
[quoted text clipped - 26 lines]
>    WS1.AutoFilterMode = False
> End Sub
Steved - 21 Jan 2007 21:35 GMT
Thanks Tom

> Only problem I would see is if you don't get any visible rows when you
> filter on City.
[quoted text clipped - 31 lines]
> >    WS1.AutoFilterMode = False
> > End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.