PC Review


Reply
Thread Tools Rate Thread

Advanced Filter Multiple Criteria Range not working

 
 
dean.brunne@lion-nathan.com.au
Guest
Posts: n/a
 
      8th May 2007
Hi,

I have used the following Advanced Filter using named ranges for the
List, Criteria and CopyToRange. The code runs but only half of the
criteria seems to work. I try the same Advanced filter manually with
the same result. What do I need to have multiple criteria work. The
criteria below works only for the Cost Centre field but not the
Company field. The Company field returns all company numbers but I
want only the one. Appreciate any help. Cheers, Dean.

CODE:

Sheets("Sheet1").Select
Range("A1").Select
Sheets("Detail").Range("Database").AdvancedFilter
Action:=xlFilterCopy, _
CriteriaRange:=Sheets("Distribution").Range("H1:I17"),
CopyToRange:=Range( _
"A1:I1"), Unique:=False

CRITERIA

Company Cost Centre
2100 4000
4010
4021
4022
4023
4025
4026

 
Reply With Quote
 
 
 
 
dean.brunne@lion-nathan.com.au
Guest
Posts: n/a
 
      8th May 2007
On May 8, 1:44 pm, dean.bru...@lion-nathan.com.au wrote:
> Hi,
>
> I have used the following Advanced Filter using named ranges for the
> List, Criteria and CopyToRange. The code runs but only half of the
> criteria seems to work. I try the same Advanced filter manually with
> the same result. What do I need to have multiple criteria work. The
> criteria below works only for the Cost Centre field but not the
> Company field. The Company field returns all company numbers but I
> want only the one. Appreciate any help. Cheers, Dean.
>
> CODE:
>
> Sheets("Sheet1").Select
> Range("A1").Select
> Sheets("Detail").Range("Database").AdvancedFilter
> Action:=xlFilterCopy, _
> CriteriaRange:=Sheets("Distribution").Range("H1:I17"),
> CopyToRange:=Range( _
> "A1:I1"), Unique:=False
>
> CRITERIA
>
> Company Cost Centre
> 2100 4000
> 4010
> 4021
> 4022
> 4023
> 4025
> 4026


Hi I have now got it to work by putting 2100 with each cost centre
however I have other filters to do where the Company list is 4 records
and the Cost Centre list is 12. Do I therefore need to create 48
combos in the criteria list or can the criteria statement be
structured differently.

NEW CRITERIA EXAMPLE:
Company Cost Centre
2100 7000
2200 7020
2300 7035
2400 7040
7045
7055
7065
7070
7075
7080
7115
7120

 
Reply With Quote
 
Debra Dalgleish
Guest
Posts: n/a
 
      8th May 2007
Create a criteria range (H1:H2) with a blank heading cell, and in the
cell below, use a formula that refers to your company list and cost
centre list. For example:

=AND(COUNTIF(Companies,F2),COUNTIF(CostCtrs,J2))

where the first company in the data is in cell F2, and the first cost
centre is in J2.

(E-Mail Removed) wrote:
> On May 8, 1:44 pm, dean.bru...@lion-nathan.com.au wrote:
>
>>Hi,
>>
>>I have used the following Advanced Filter using named ranges for the
>>List, Criteria and CopyToRange. The code runs but only half of the
>>criteria seems to work. I try the same Advanced filter manually with
>>the same result. What do I need to have multiple criteria work. The
>>criteria below works only for the Cost Centre field but not the
>>Company field. The Company field returns all company numbers but I
>>want only the one. Appreciate any help. Cheers, Dean.
>>
>>CODE:
>>
>>Sheets("Sheet1").Select
>> Range("A1").Select
>> Sheets("Detail").Range("Database").AdvancedFilter
>>Action:=xlFilterCopy, _
>> CriteriaRange:=Sheets("Distribution").Range("H1:I17"),
>>CopyToRange:=Range( _
>> "A1:I1"), Unique:=False
>>
>>CRITERIA
>>
>>Company Cost Centre
>>2100 4000
>> 4010
>> 4021
>> 4022
>> 4023
>> 4025
>> 4026

>
>
> Hi I have now got it to work by putting 2100 with each cost centre
> however I have other filters to do where the Company list is 4 records
> and the Cost Centre list is 12. Do I therefore need to create 48
> combos in the criteria list or can the criteria statement be
> structured differently.
>
> NEW CRITERIA EXAMPLE:
> Company Cost Centre
> 2100 7000
> 2200 7020
> 2300 7035
> 2400 7040
> 7045
> 7055
> 7065
> 7070
> 7075
> 7080
> 7115
> 7120
>



--
Debra Dalgleish
Contextures
http://www.contextures.com/tiptech.html

 
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
Advanced Filter - Criteria Range issue Tina Microsoft Excel Misc 4 11th Jun 2009 03:28 PM
Advanced Filter using a range name as the criteria Joe Microsoft Excel Worksheet Functions 1 27th Dec 2008 06:23 PM
Advanced Filter VB Script for Variable Criteria Range =?Utf-8?B?SmFzb24=?= Microsoft Excel Programming 2 19th Jun 2006 07:15 AM
Advanced filter and Criteria Range =?Utf-8?B?Z2Vhcm9pZA==?= Microsoft Excel Misc 2 20th Jul 2005 02:33 PM
VBA Advanced Filter Criteria (How to insert UsedRange in Range Sta =?Utf-8?B?RGVubmlz?= Microsoft Excel Misc 2 26th Oct 2004 12:57 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:22 AM.