Quantcast
Channel: Excel IT Pro Discussions forum
Viewing all articles
Browse latest Browse all 11829

trying to set up a filter in excel with VBA

$
0
0

Hi there,

I have recently been getting back into VBA, and I have come across something I am unable to spot where I have gone wrong.

I have set up a report using a pivot table and I have trying to sort out in specific date range. for example in need to show information that is 0-1 day old, 1-3, 3-5 and so on. The code I'm using is

Dim todayDate As Date
Dim yesterday As Date

todayDate = Format(Now, "dd, mm, yyyy")
yesterday = Format(Now - 1, "dd, mm, yyyy")

Sheets("Dates").Select
    ActiveSheet.PivotTables("Dates").PivotFields("Reported Date+").PivotFilter.Add Type:=xlDateBetween, Value1:=yesterday, Value2:=todayDate

Can anyone help me out on this one?


Viewing all articles
Browse latest Browse all 11829

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>