PC Review


Reply
Thread Tools Rate Thread

How do I copy an autofilter using a macro?

 
 
=?Utf-8?B?QXN0b25naXptbw==?=
Guest
Posts: n/a
 
      21st Nov 2006
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.


 
Reply With Quote
 
 
 
 
Kathy
Guest
Posts: n/a
 
      21st Nov 2006
Have you considered using Advanced filter to do this? Just remember to start
on the destination page.

"Astongizmo" <(E-Mail Removed)> wrote in message
news82930B8-6299-4F79-AE52-(E-Mail Removed)...
> 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.
>
>



 
Reply With Quote
 
N10
Guest
Posts: n/a
 
      22nd Nov 2006
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" <(E-Mail Removed)> wrote in message
news82930B8-6299-4F79-AE52-(E-Mail Removed)...
> 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.
>
>



 
Reply With Quote
 
Dana DeLouis
Guest
Posts: n/a
 
      22nd Nov 2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news82930B8-6299-4F79-AE52-(E-Mail Removed)...
>> 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.
>>
>>

>
>



 
Reply With Quote
 
=?Utf-8?B?QXN0b25naXptbw==?=
Guest
Posts: n/a
 
      22nd Nov 2006
Thanks for taking the time to respond. I've never used code before either, so
how do I do the first bit "With code select the filtered range"?

"N10" wrote:

> 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" <(E-Mail Removed)> wrote in message
> news82930B8-6299-4F79-AE52-(E-Mail Removed)...
> > 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.
> >
> >

>
>
>

 
Reply With Quote
 
=?Utf-8?B?QXN0b25naXptbw==?=
Guest
Posts: n/a
 
      22nd Nov 2006
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message
> > news82930B8-6299-4F79-AE52-(E-Mail Removed)...
> >> 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.
> >>
> >>

> >
> >

>
>
>

 
Reply With Quote
 
=?Utf-8?B?QXN0b25naXptbw==?=
Guest
Posts: n/a
 
      22nd Nov 2006
Hi Kathy,

Thanks for taking the time out to reply. I'm doing this work for somebody
else and unfortunately they are relatively inexperienced with Excel. For this
reason and tyhis reason alone we are tryinging to automate the process as
much as possible. Advanced autofilter will blow the guys mind.

Have a nice day.

"Kathy" wrote:

> Have you considered using Advanced filter to do this? Just remember to start
> on the destination page.
>
> "Astongizmo" <(E-Mail Removed)> wrote in message
> news82930B8-6299-4F79-AE52-(E-Mail Removed)...
> > 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.
> >
> >

>
>
>

 
Reply With Quote
 
N10
Guest
Posts: n/a
 
      22nd Nov 2006
HI AStongizmo

Ill write a demo for you latter today which includes the suggestions made
by Dana

Have to work now

Best N10
"Astongizmo" <(E-Mail Removed)> wrote in message
news:8145B3FC-73FB-400E-A793-(E-Mail Removed)...
> Thanks for taking the time to respond. I've never used code before either,
> so
> how do I do the first bit "With code select the filtered range"?
>
> "N10" wrote:
>
>> 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" <(E-Mail Removed)> wrote in message
>> news82930B8-6299-4F79-AE52-(E-Mail Removed)...
>> > 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.
>> >
>> >

>>
>>
>>



 
Reply With Quote
 
Roger Govier
Guest
Posts: n/a
 
      22nd Nov 2006
Hi

Before ruling out Kathy's suggestion totally, using Advanced Filter with
a button to invoke the required code is a very simple routine that even
some of my very inexperienced Excel clients can handle without any
difficulty.
Simple dropdowns on the Report sheet to make the selections they want,
then one button click and they can see just the data they need, not all
of the data in the main table.

Take a look at Debra Dalgleish's site for instructions on setting up and
using Advanced Filter with macros. There are also a number of
downloadable files with code set up that you can probably modify to suit
your needs.
http://www.contextures.com/xladvfilter02.html
http://www.contextures.com/excelfiles.html

--
Regards

Roger Govier


"Astongizmo" <(E-Mail Removed)> wrote in message
news:3D5A975B-A4BA-42DA-B914-(E-Mail Removed)...
> Hi Kathy,
>
> Thanks for taking the time out to reply. I'm doing this work for
> somebody
> else and unfortunately they are relatively inexperienced with Excel.
> For this
> reason and tyhis reason alone we are tryinging to automate the process
> as
> much as possible. Advanced autofilter will blow the guys mind.
>
> Have a nice day.
>
> "Kathy" wrote:
>
>> Have you considered using Advanced filter to do this? Just remember
>> to start
>> on the destination page.
>>
>> "Astongizmo" <(E-Mail Removed)> wrote in message
>> news82930B8-6299-4F79-AE52-(E-Mail Removed)...
>> > 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.
>> >
>> >

>>
>>
>>



 
Reply With Quote
 
=?Utf-8?B?QXN0b25naXptbw==?=
Guest
Posts: n/a
 
      22nd Nov 2006
Hi N10,

Really appreciate your support. Cheers.

"N10" wrote:

> HI AStongizmo
>
> Ill write a demo for you latter today which includes the suggestions made
> by Dana
>
> Have to work now
>
> Best N10
> "Astongizmo" <(E-Mail Removed)> wrote in message
> news:8145B3FC-73FB-400E-A793-(E-Mail Removed)...
> > Thanks for taking the time to respond. I've never used code before either,
> > so
> > how do I do the first bit "With code select the filtered range"?
> >
> > "N10" wrote:
> >
> >> 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" <(E-Mail Removed)> wrote in message
> >> news82930B8-6299-4F79-AE52-(E-Mail Removed)...
> >> > 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.
> >> >
> >> >
> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy autofilter row by row =?Utf-8?B?U2hsb21pdA==?= Microsoft Excel Discussion 1 12th Nov 2006 10:38 PM
macro to autofilter other file and copy in opened file matthias Microsoft Excel Programming 4 17th Aug 2006 10:52 AM
Questions: Copy ranges, autofilter macro, subtotals, & naming shee =?Utf-8?B?U21hbmdsZXI=?= Microsoft Excel Programming 2 11th Jun 2006 05:37 PM
Autofilter copy Mike Fogleman Microsoft Excel Programming 3 5th Dec 2005 08:23 PM
Copy Autofilter results macro =?Utf-8?B?Q0xS?= Microsoft Excel Programming 7 16th May 2005 06:48 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:34 AM.