View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Astongizmo Astongizmo is offline
external usenet poster
 
Posts: 6
Default How do I copy an autofilter using a macro?

Hi Dana,

Please see my response to N10 - really appreciate your input.

I am a virgin code user so does your section go before or after the code
suggested by N10?

Thanks once again.

"Dana DeLouis" wrote:

In addition to this excellent idea, if you wish not to copy the Heading Row,
just offset by 1.

Sub Demo()
Dim rngTo As Range

Set rngTo = Sheets(2).Range("A1")

ActiveSheet.AutoFilter.Range. _
Offset(1).Copy rngTo
End Sub

--
HTH :)
Dana DeLouis
Windows XP & Office 2003


"N10" wrote in message
...
Hi

Try this


With code select the filtered range

then use

Selection.SpecialCell(xlCellTypeVisible).Select
Selection.Copy

This copies only the cells visble as a result of the filter criteria

N10 ;)



"Astongizmo" wrote in message
...
Hi - I'm new to macros and the answer to my question is probably already
posted.

I have a spreadsheet containing an autofilter. This always returns the
same
number of columns but the number of rows can vary. I want to copy the
displayed rows only to a second sheet building up a list on the second
sheet,
so each time I select a new filter the result will be copied to the
second
sheet below any data already there. As a second stage I want to sort the
second sheet and extract all rows where a certain column matches a fixed
criteria into a further sheet. This second stage will require to be done
twice as the criteria changes.

Any help will be gratefully received.