Is it impossible to AutoFilter based on a range of values?

Eric G

New Member
Joined
Dec 21, 2017
Messages
47
Need to AutoFilter based on a range of values, such as:
Code:
[LEFT][COLOR=#000000][FONT=Calibri]Worksheets("Sheet2").Range("A1:A5").Value[/FONT][/COLOR][/LEFT]

When the range code is inserted into the rest of the VBA code, such as:
Code:
[COLOR=#222222][FONT=Calibri][SIZE=3][COLOR=#000000]Worksheets("Sheet1").Range("$A$5:$C$100").AutoFilterField:=2, Criteria1:=Worksheets("Sheet2").Range("A1:A5").Value[/COLOR][/SIZE][/FONT][/COLOR]

The code filters only for the value in A5. The remaining values in the range are ignored.

Any ideas on how to AutoFilter based on a range of values?
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
How about
Code:
Dim ary As Variant
ary = Worksheets("Sheet2").Range("A1:A5").Value
Worksheets("Sheet1").Range("$A$5:$C$100").AutoFilter 2, Application.Transpose(ary), xlFilterValues
 
Upvote 0
How about
Code:
Dim ary As Variant
ary = Worksheets("Sheet2").Range("A1:A5").Value
Worksheets("Sheet1").Range("$A$5:$C$100").AutoFilter 2, Application.Transpose(ary), xlFilterValues

You're a Godsend. Where did you learn all of this stuff??? Incredible. Thanks, Fluff.
 
Last edited:
Upvote 0
You're welcome & thanks for the feedback.

I learnt most of what I know from this wonderful site :)
 
Upvote 0
I don't think so, I think Fluff was born with all that wisdom :pray:
 
Upvote 0
Nice of you to say so, but I consider myself to be an enthusiastic amateur and have learnt a formidable amount (either directly or indirectly) from a lot of the other members here.
 
Upvote 0

Forum statistics

Threads
1,214,515
Messages
6,119,972
Members
448,933
Latest member
Bluedbw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top