Reference named range in AutoFilter criteria

Celly

Board Regular
Joined
Jan 29, 2015
Messages
84
Office Version
  1. 2016
Platform
  1. Windows
I am trying to reference a named range in an AutoFilter like so:

Example 1

VBA Code:
[Range1].AutoFilter field:=1, Criteria1:=">='" & ThisWorkbook.Name & "'![Range2]", VisibleDropDown:=False

No syntax seems to work. I can convert range2 to a string, and that is fine:

Example 2

VBA Code:
[Range1].AutoFilter field:=1, Criteria1:=">=" & [Range2], VisibleDropDown:=False

It really isn't the same thing, it becomes static versus dynamic. I would prefer Example1 for performance and simplicity in refreshing the filter. In other words, this would theoretically refresh changes to Range1:

VBA Code:
Sheet1.AutoFilter.ApplyFilter

In Example 2, the AutoFilter has to be regenerated.
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
I think that what you wanted is only possible with a worksheet_change event.
 
Upvote 0
I think that what you wanted is only possible with a worksheet_change event.
Yeah I didn't believe this is possible, but I'm often surprised with Excel. Oh well.
 
Upvote 0

Forum statistics

Threads
1,214,951
Messages
6,122,442
Members
449,083
Latest member
Ava19

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