Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 519
Default Will not copy to City-Panmure

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Will not copy to City-Panmure

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.

--
Regards,
Tom Ogilvy

"Steved" wrote in message
...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 519
Default Will not copy to City-Panmure

Thanks Tom

"Tom Ogilvy" wrote:

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.

--
Regards,
Tom Ogilvy

"Steved" wrote in message
...
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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
City State Zip Texas Nuckols Excel Discussion (Misc queries) 3 August 7th 07 10:56 PM
city st zip cells Joanne[_4_] Excel Programming 8 September 22nd 06 03:18 PM
Adds City but not Panmure ( Combined Total ) Steved Excel Worksheet Functions 6 June 27th 06 11:02 PM
1 will be City, 2 will be Roskill and so on please. Steved Excel Worksheet Functions 4 August 16th 05 03:26 AM
1=City, 2=Roskill Steved Excel Worksheet Functions 8 August 16th 05 03:19 AM


All times are GMT +1. The time now is 10:00 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"