PC Review


Reply
Thread Tools Rate Thread

AdvancedFilter problem

 
 
Whit
Guest
Posts: n/a
 
      4th Apr 2008
I am trying to get a unique list of items using an the advancedfilter method
but it keeps pasting the data to the wrong sheet. I cannot see how this is
happening as i thought that the paste range had to be on the same sheet?


ActiveSheet.Range("B1:B" & ActiveSheet.UsedRange.Rows.Count).AdvancedFilter _
Action:=xlFilterCopy, CopyToRange:=Range("M1"), Unique:=True

Cheers

Whit
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      4th Apr 2008
You can put the filtered list on any sheet you want.

But if your code is behind a worksheet, then that unqualified range
(copytorange) will refer to the sheet that owns the code--not always the
activesheet.

I'd try this first.

ActiveSheet.Range("B1:B" & ActiveSheet.UsedRange.Rows.Count).AdvancedFilter _
Action:=xlFilterCopy, CopyToRange:=activesheet.Range("M1"), Unique:=True

or

with activesheet
.Range("B1:B" & .UsedRange.Rows.Count).AdvancedFilter _
Action:=xlFilterCopy, CopyToRange:=.Range("M1"), Unique:=True
end with

(to avoid some typing)

Whit wrote:
>
> I am trying to get a unique list of items using an the advancedfilter method
> but it keeps pasting the data to the wrong sheet. I cannot see how this is
> happening as i thought that the paste range had to be on the same sheet?
>
> ActiveSheet.Range("B1:B" & ActiveSheet.UsedRange.Rows.Count).AdvancedFilter _
> Action:=xlFilterCopy, CopyToRange:=Range("M1"), Unique:=True
>
> Cheers
>
> Whit


--

Dave Peterson
 
Reply With Quote
 
Whit
Guest
Posts: n/a
 
      4th Apr 2008
thanks it worked

"Dave Peterson" wrote:

> You can put the filtered list on any sheet you want.
>
> But if your code is behind a worksheet, then that unqualified range
> (copytorange) will refer to the sheet that owns the code--not always the
> activesheet.
>
> I'd try this first.
>
> ActiveSheet.Range("B1:B" & ActiveSheet.UsedRange.Rows.Count).AdvancedFilter _
> Action:=xlFilterCopy, CopyToRange:=activesheet.Range("M1"), Unique:=True
>
> or
>
> with activesheet
> .Range("B1:B" & .UsedRange.Rows.Count).AdvancedFilter _
> Action:=xlFilterCopy, CopyToRange:=.Range("M1"), Unique:=True
> end with
>
> (to avoid some typing)
>
> Whit wrote:
> >
> > I am trying to get a unique list of items using an the advancedfilter method
> > but it keeps pasting the data to the wrong sheet. I cannot see how this is
> > happening as i thought that the paste range had to be on the same sheet?
> >
> > ActiveSheet.Range("B1:B" & ActiveSheet.UsedRange.Rows.Count).AdvancedFilter _
> > Action:=xlFilterCopy, CopyToRange:=Range("M1"), Unique:=True
> >
> > Cheers
> >
> > Whit

>
> --
>
> Dave Peterson
>

 
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
AdvancedFilter VBA Sandy Microsoft Excel Discussion 10 14th Feb 2008 06:10 PM
Advancedfilter =?Utf-8?B?cmFt?= Microsoft Excel Programming 1 30th Dec 2005 02:18 AM
AdvancedFilter in VB loopy Microsoft Excel Programming 1 22nd Jun 2005 03:24 PM
VBA - AdvancedFilter Ben Microsoft Excel Discussion 2 24th Feb 2004 10:43 AM
Excel Advancedfilter problem - AND or OR ??? p cooper Microsoft Excel Misc 0 29th Jul 2003 09:49 PM


Features
 

Advertising
 

Newsgroups
 


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