Auto Filter VBA using a formula

ItalianPlatinum

Well-known Member
Joined
Mar 23, 2017
Messages
793
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Looking to find a way to use auto filter to filter out using a formula

VBA Code:
.Range("1:1").AutoFilter Field:=2, Criteria1:="=TEXT(Today(),YYYYMMDD)"

The column as of now has two dates in YYYYMMDD number format. I only want to filter to see today so 3/31 the above isnt work and I cant quite get it to work i want to refrain from adding any helper columns if possible

20220331
20220401
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Looking to find a way to use auto filter to filter out using a formula

VBA Code:
.Range("1:1").AutoFilter Field:=2, Criteria1:="=TEXT(Today(),YYYYMMDD)"

The column as of now has two dates in YYYYMMDD number format. I only want to filter to see today so 3/31 the above isnt work and I cant quite get it to work i want to refrain from adding any helper columns if possible

20220331
20220401

See if this works for you:

VBA Code:
Range("1:1").AutoFilter 2, 1, 11
 
Upvote 0
Didn't seem to work

1648772172318.png
 
Upvote 0
use evaluate with the worksheet function string, also the " must be double.
VBA Code:
Range("1:1").AutoFilter 2, Evaluate("=text(today(),""yyyymmdd"")")
 
Upvote 0
Solution
look
use evaluate with the worksheet function string, also the " must be double.
VBA Code:
Range("1:1").AutoFilter 2, Evaluate("=text(today(),""yyyymmdd"")")
this look to have worked going to test little bit further to validate
 
Upvote 0

Forum statistics

Threads
1,215,006
Messages
6,122,666
Members
449,091
Latest member
peppernaut

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