Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
sgl sgl is offline
external usenet poster
 
Posts: 80
Default for Tom Ogilvy Please

Tom Hi,
I have copied your CopyFilter sub from the Contextures site but want to copy
to a new worksheet a "specific range" rather than the whole of the filtered
area. I have amended your code as shown below but cannot get the range
parameters right. Your assistance please.

Sub CopyFilter2()
'by Tom Ogilvy
Dim rng As Range
Dim rng2 As Range
Dim rng3 As Long

Application.ScreenUpdating = False
Range("A5").AutoFilter Field:=1, Criteria1:="01"

With ActiveSheet.AutoFilter.Range
On Error Resume Next
Set rng2 = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
End With
If rng2 Is Nothing Then
MsgBox "No data to copy"
Else
Worksheets("Sheet2").Range("A2:L25").ClearContents
Set rng = ActiveSheet.AutoFilter.Range

' I have added this to count visible rows
rng3 = rng.Columns(4).SpecialCells(xlCellTypeVisible).Cou nt - 1

' Range I want to copy starts in the first row column 4 of filtered
' range to the last cell in say Column 10 of the filtered range

Range(Cells(rng.Offset(1, 4), rng.Columns(4)), _
Cells(rng3, rng.Columns(10))).Copy

Worksheets("Sheet2").Range("A2").PasteSpecial Paste:=xlValues

End If
On Error Resume Next
ActiveSheet.ShowAllData

Application.ScreenUpdating = True
End Sub

Many thanks in davance/sgl


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
For Tom Ogilvy JLGWhiz Excel Programming 1 September 11th 06 03:08 AM
Tom Ogilvy again Jonsson Excel Programming 3 September 19th 04 05:09 PM
Tom Ogilvy Jonsson Excel Programming 4 September 18th 04 01:18 AM
Tom Ogilvy halem2[_26_] Excel Programming 4 September 17th 04 03:26 PM
tom ogilvy? somebody? rbekka33[_13_] Excel Programming 0 September 17th 04 03:28 AM


All times are GMT +1. The time now is 06:23 PM.

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

About Us

"It's about Microsoft Excel"