Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 74
Default Filter and copy question

I have the following code to filter a data sheet. How can include a code to
copy the filtered data and place it in a sheet called "Z"?

Sub ApplyFilter()
Dim wsDL As Worksheet
Dim wsO As Worksheet
Dim rngAD As Range
Set wsDL = Sheets("DateList")
Set wsO = Sheets("Orders")
Set rngAD = wsO.Range("AllDates")
'update the list of dates
wsDL.Range("A1").CurrentRegion.ClearContents
'rngAD.Offset(-1, 0).Resize(rngAD.Rows.Count + 1).Select
rngAD.AdvancedFilter _
Action:=xlFilterCopy, CriteriaRange:="", _
CopyToRange:=wsDL.Range("A1"), Unique:=True
wsDL.Range("A1").CurrentRegion.Sort _
Key1:=wsDL.Range("A2"), Order1:=xlAscending, header:=xlYes
'filter the list
wsO.Range("Database").AdvancedFilter _
Action:=xlFilterInPlace, _
CriteriaRange:=wsO.Range("G1:H2"), Unique:=False
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8
Default Filter and copy question


I think a quick way to do it would be to select your range after you have
filtered your data and then use:

Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Sheet("Z").Cells(1,1).PasteSpecial


Hope this helps!


"hoyos" wrote:

I have the following code to filter a data sheet. How can include a code to
copy the filtered data and place it in a sheet called "Z"?

Sub ApplyFilter()
Dim wsDL As Worksheet
Dim wsO As Worksheet
Dim rngAD As Range
Set wsDL = Sheets("DateList")
Set wsO = Sheets("Orders")
Set rngAD = wsO.Range("AllDates")
'update the list of dates
wsDL.Range("A1").CurrentRegion.ClearContents
'rngAD.Offset(-1, 0).Resize(rngAD.Rows.Count + 1).Select
rngAD.AdvancedFilter _
Action:=xlFilterCopy, CriteriaRange:="", _
CopyToRange:=wsDL.Range("A1"), Unique:=True
wsDL.Range("A1").CurrentRegion.Sort _
Key1:=wsDL.Range("A2"), Order1:=xlAscending, header:=xlYes
'filter the list
wsO.Range("Database").AdvancedFilter _
Action:=xlFilterInPlace, _
CriteriaRange:=wsO.Range("G1:H2"), Unique:=False
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 74
Default Filter and copy question

Thanks Peabrain25 that was useful

"peabrain25" wrote:


I think a quick way to do it would be to select your range after you have
filtered your data and then use:

Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Sheet("Z").Cells(1,1).PasteSpecial


Hope this helps!


"hoyos" wrote:

I have the following code to filter a data sheet. How can include a code to
copy the filtered data and place it in a sheet called "Z"?

Sub ApplyFilter()
Dim wsDL As Worksheet
Dim wsO As Worksheet
Dim rngAD As Range
Set wsDL = Sheets("DateList")
Set wsO = Sheets("Orders")
Set rngAD = wsO.Range("AllDates")
'update the list of dates
wsDL.Range("A1").CurrentRegion.ClearContents
'rngAD.Offset(-1, 0).Resize(rngAD.Rows.Count + 1).Select
rngAD.AdvancedFilter _
Action:=xlFilterCopy, CriteriaRange:="", _
CopyToRange:=wsDL.Range("A1"), Unique:=True
wsDL.Range("A1").CurrentRegion.Sort _
Key1:=wsDL.Range("A2"), Order1:=xlAscending, header:=xlYes
'filter the list
wsO.Range("Database").AdvancedFilter _
Action:=xlFilterInPlace, _
CriteriaRange:=wsO.Range("G1:H2"), Unique:=False
End Sub

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 561
Default Filter and copy question

As far as I recall, in that case, the line:
Selection.SpecialCells(xlCellTypeVisible).Select
is unnecessary - because running copy/paste on a Filtered range will paste -
by default - only the visible cells.
Micky


"peabrain25" wrote:


I think a quick way to do it would be to select your range after you have
filtered your data and then use:

Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Sheet("Z").Cells(1,1).PasteSpecial


Hope this helps!


"hoyos" wrote:

I have the following code to filter a data sheet. How can include a code to
copy the filtered data and place it in a sheet called "Z"?

Sub ApplyFilter()
Dim wsDL As Worksheet
Dim wsO As Worksheet
Dim rngAD As Range
Set wsDL = Sheets("DateList")
Set wsO = Sheets("Orders")
Set rngAD = wsO.Range("AllDates")
'update the list of dates
wsDL.Range("A1").CurrentRegion.ClearContents
'rngAD.Offset(-1, 0).Resize(rngAD.Rows.Count + 1).Select
rngAD.AdvancedFilter _
Action:=xlFilterCopy, CriteriaRange:="", _
CopyToRange:=wsDL.Range("A1"), Unique:=True
wsDL.Range("A1").CurrentRegion.Sort _
Key1:=wsDL.Range("A2"), Order1:=xlAscending, header:=xlYes
'filter the list
wsO.Range("Database").AdvancedFilter _
Action:=xlFilterInPlace, _
CriteriaRange:=wsO.Range("G1:H2"), Unique:=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
Copy only visible cells after filter is applied/ sum after filter MAM Excel Worksheet Functions 0 April 9th 08 04:09 AM
Filter Question May Excel Discussion (Misc queries) 1 October 23rd 07 12:47 PM
Filter question Bg Excel Worksheet Functions 7 July 4th 06 08:45 PM
Filter Question bodhisatvaofboogie Excel Discussion (Misc queries) 1 June 20th 06 04:23 PM
a filter question [email protected] Excel Discussion (Misc queries) 3 May 16th 06 08:59 PM


All times are GMT +1. The time now is 05:45 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"