Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default Automate Autofilter Results - Copy to New Sheet

Hello All! I hope someone can help. I have used the macro recorder, and can
do some editing safely, but I am stuck. I need to run the autofilter on a
field several times looking for "begins with" and "contains" conditions
stored in another Excel file. I don't mind pasting all these conditions into
the code, but there may be a more efficient way?

The main problem is that I cannot copy to a new sheet and insert the copied
cells to that sheet (shift cells down - or paste append) without including
the Autofilter Row (1) and blank cells. I am filtering and copying from a
sheet named "Good" to a sheet named "Skip". This is my failing code so far:

Columns("A:AJ").Select
Selection.AutoFilter Field:=5, Criteria1:="=zz*", Operator:=xlAnd
ActiveSheet.UsedRange.SpecialCells(xlCellTypeVisib le).Copy
Sheets("Skip").Select.Range("A2").Insert Shift:=xlDown

Any help will be most appreciated. Thank you.
Annie
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Automate Autofilter Results - Copy to New Sheet

Hi Annie,

Assuming your range is contiguous you could use the CurrentRegion rather
than full Columns. If not, change back. Also, I assumed you wanted to append
to the next empty row on "Skip".

Sub AFAnn()
Dim rng As Range

Sheets("Good").Select
Set rng = Sheets("Good").Range("A1").CurrentRegion
rng.AutoFilter Field:=5, Criteria1:="=zz*"

'the following statement removes the first or header row
Set rng = rng.Offset(1, 0).Resize(rng.Rows.Count - 1)
Set rng = rng.SpecialCells(xlVisible)

'copies to the first empty row in Column A
rng.Copy Sheets("Skip").Range("A65536").End(xlUp).Offset(1, 0)
Selection.AutoFilter
End Sub

CHORDially,
Art Farrell


"Annie" wrote in message
...
Hello All! I hope someone can help. I have used the macro recorder, and

can
do some editing safely, but I am stuck. I need to run the autofilter on a
field several times looking for "begins with" and "contains" conditions
stored in another Excel file. I don't mind pasting all these conditions

into
the code, but there may be a more efficient way?

The main problem is that I cannot copy to a new sheet and insert the

copied
cells to that sheet (shift cells down - or paste append) without including
the Autofilter Row (1) and blank cells. I am filtering and copying from a
sheet named "Good" to a sheet named "Skip". This is my failing code so

far:

Columns("A:AJ").Select
Selection.AutoFilter Field:=5, Criteria1:="=zz*", Operator:=xlAnd
ActiveSheet.UsedRange.SpecialCells(xlCellTypeVisib le).Copy
Sheets("Skip").Select.Range("A2").Insert Shift:=xlDown

Any help will be most appreciated. Thank you.
Annie



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default Automate Autofilter Results - Copy to New Sheet

Hi Art,
Your solution provided me with the perfect framework for a solution. I added
some error trapping, and I'm on my way! Thank you so much.
Annie


"Art Farrell" wrote:

Hi Annie,

Assuming your range is contiguous you could use the CurrentRegion rather
than full Columns. If not, change back. Also, I assumed you wanted to append
to the next empty row on "Skip".

Sub AFAnn()
Dim rng As Range

Sheets("Good").Select
Set rng = Sheets("Good").Range("A1").CurrentRegion
rng.AutoFilter Field:=5, Criteria1:="=zz*"

'the following statement removes the first or header row
Set rng = rng.Offset(1, 0).Resize(rng.Rows.Count - 1)
Set rng = rng.SpecialCells(xlVisible)

'copies to the first empty row in Column A
rng.Copy Sheets("Skip").Range("A65536").End(xlUp).Offset(1, 0)
Selection.AutoFilter
End Sub

CHORDially,
Art Farrell


"Annie" wrote in message
...
Hello All! I hope someone can help. I have used the macro recorder, and

can
do some editing safely, but I am stuck. I need to run the autofilter on a
field several times looking for "begins with" and "contains" conditions
stored in another Excel file. I don't mind pasting all these conditions

into
the code, but there may be a more efficient way?

The main problem is that I cannot copy to a new sheet and insert the

copied
cells to that sheet (shift cells down - or paste append) without including
the Autofilter Row (1) and blank cells. I am filtering and copying from a
sheet named "Good" to a sheet named "Skip". This is my failing code so

far:

Columns("A:AJ").Select
Selection.AutoFilter Field:=5, Criteria1:="=zz*", Operator:=xlAnd
ActiveSheet.UsedRange.SpecialCells(xlCellTypeVisib le).Copy
Sheets("Skip").Select.Range("A2").Insert Shift:=xlDown

Any help will be most appreciated. Thank you.
Annie




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
Creating copy of sheet into new file results in #REF errors Sungibungi Excel Discussion (Misc queries) 1 December 9th 09 08:52 PM
Sort by Date and Copy results to another sheet Pat-UK New Users to Excel 6 March 17th 08 12:02 PM
create sheet from autofilter results umba-sr Excel Discussion (Misc queries) 1 February 21st 06 01:34 PM
Copy Autofilter results macro CLR Excel Programming 7 May 16th 05 06:48 PM
Automate Finding Values/Copy to Different Sheet [email protected] Excel Programming 1 March 21st 05 06:29 PM


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