Reputation: 61
Why AutoFilter function doesn't work. I have made easy code in VBA that will filter table to doesn't show row with date that is before today. Code looks like below:
Range("A:C").AutoFilter Field:=3, Criteria1:=">" & Date
Column C looks like: 22.01.2020 etc.
The code works because it was filter some dates that year was 2019 but it didn't do the work with previous date but in 2020. Why?
EDIT:
I find out something. I just replace values in that column via VBA before and values are simply date but they are on a left sight. If I just click on the value, does nothing and click enter it's kinda refresh and works fine. How to refresh cells like this in VBA?
Upvotes: 0
Views: 57
Reputation: 156
It looks like your dates are represented as string.
Please select column C where your dates are included and perform the following
Data > Text to Column > Finish
VBA Equivalent:
Range("C:C").TextToColumns
Range("A:C").AutoFilter Field:=3, Criteria1:=">" & Date
Upvotes: 1