Filter fail

Dr. Demento

Well-known Member
Joined
Nov 2, 2010
Messages
618
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
Can anyone tell me why this bit of code keeps stopping my sub? I have error handling (debug.print err.number/.description) but it doesn't throw any errors :confused: There are no erroneous dates, missing dates, or anything like that. It actually filters the column but then it quits!

VBA Code:
dim dt as date
    dt = (Date - (Weekday(Date, vbSunday) - 1))

   tbl.Range.AutoFilter Field:=6, _
                      Operator:=xlFilterValues, _
                      Criteria1:=">=" & DateSerial(Year(dt), 1, 1), _
                      Operator:=xlAnd, _
                      Criteria2:="<=" & dt

I have no idea!! Thanks y'all.
 
Last edited:

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.
You can't have two Operator arguments, and the first one doesn't make sense anyway, so remove it.
 
Upvote 0
It looks like you formatted Criteria1 different from Criteria2.
 
Upvote 0
Well Rory . . .

easy-button.jpg
Thank you!!


C Moore - the formats aren't meant to be different, one is just for 01 Jan and the other for the nearest Sunday. Appreciate the time.
 
Upvote 0

Forum statistics

Threads
1,215,545
Messages
6,125,455
Members
449,228
Latest member
moaz_cma

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