PC Review


Reply
Thread Tools Rate Thread

AutoFilter Criteria using named range

 
 
Len
Guest
Posts: n/a
 
      4th Sep 2010
Hi,

I tried to use named range as AutoFilter criteria but it fails to work
using codes below
In fact I need to filter column B in sheet1 under workbook A based on
range("A1:A10") in sheet5 of workbook B

Codes extract

With Workbooks("B.xls").Sheets(5)
..Range("A1", Range("A65536").End(xlUp)).Name = "MyRange"
End With
Workbooks("A.xls").activate
Sheets(1).Select
Selection.AutoFilter Field:=2, Criteria1:=MyRange,
Operator:=xlFilterValues

Any helps will be much appreciated and thanks in advance


Regards
Len


 
Reply With Quote
 
 
 
 
Javed
Guest
Posts: n/a
 
      4th Sep 2010
Autofilter does not take range as criteria.I have used Advanced
Filter.Hope this will solve

With Workbooks("B.xls").Sheets(5)
Range(.Range("A1"), .Range("A65536").End(xlUp)).Name = "MyRange"
End With
Workbooks("A.xls").Activate
Sheets(1).Select


If Selection Is Nothing Then
MsgBox "select ...."
Exit Sub
End If

Selection.AdvancedFilter Action:=xlFilterInPlace,
criteriarange:=Workbooks("B.xls").Worksheets(5).Range("MyRange")
 
Reply With Quote
 
Len
Guest
Posts: n/a
 
      6th Sep 2010
Javed,

Thanks for prompt reply and your codes.
After working around with your codes in Excel 2007, there is no
response to advance filtering and prompt the message as there is no
selection made

Please help

Thanks & Regards
Len


 
Reply With Quote
 
Javed
Guest
Posts: n/a
 
      6th Sep 2010
Dear Len,

You must select the required data before running.(I have given error
trap so that if no selection this macro exits)

Advanced Filter requires one Criteria Range.Suppose your data contains
names of Customer with columnheading "Name"
Then the value of first cell in MyRange should be Name after that any
thing you want to filter may be existing.

Myrange-Cell 1 -->Name (The column heading should be exactly as per
the original column of data)
MyRange Cell2,3,4.....-->>Cutomer Name you want to filter

If it is a bit complex you may just send the two waorkbook filling
necessary data in MyRange.I will fulfill remaining.

 
Reply With Quote
 
Len
Guest
Posts: n/a
 
      6th Sep 2010
Dear Javed,

Thanks for your advice
Finally, It works perfectly using named range in advance filtering

It is bit confuse that since we can use array in criteria selection
for Auto filtering and why array can not be replaced by named range
for auto filtering


Cheers
Len

 
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
Autofilter using range from another sheet as the criteria Robert Microsoft Excel Programming 0 23rd Jun 2009 09:41 PM
Can I use a named range in the criteria for a sumif? =?Utf-8?B?cmZ0bXN0?= Microsoft Excel Worksheet Functions 2 1st Sep 2007 03:50 PM
named range with criteria. =?Utf-8?B?ZHJpbGxlcg==?= Microsoft Excel Worksheet Functions 7 12th Jul 2007 11:04 PM
Named Range Change Based On AutoFilter SanctifiedRock Microsoft Excel Programming 3 16th May 2006 03:27 PM
AutoFilter to Named Range odie Microsoft Excel Discussion 1 23rd Sep 2003 11:16 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:16 AM.