picking the last 7 days in a pivot chart

hattrick_123

New Member
Joined
Apr 5, 2011
Messages
7
Hi there <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
<o:p> </o:p>
I am looking to write a macro that makes the last 7 days in the pivot chart visible. I am assuming all days are visible before the macro is run. So then when the macro is run, only the last 7 days are visible in the pivot chart. <o:p></o:p>
<o:p> </o:p>
My initial thinking is to make all the dates invisible/hidden and then make the last 7 days visible. But I am not too sure if this is the best method?<o:p></o:p>
<o:p> </o:p>
The below macro is a simple recording of the “date” being filtered to only show last weeks days. <o:p></o:p>
<o:p> </o:p>
How do I write the below code so it could be written generically so I can put it in a loop to do every pivot chart in a workbook? I can work on the loop myself. I just need a hand with this part please.<o:p></o:p>
<o:p> </o:p>
<o:p> </o:p>
Code:
[COLOR=black][FONT=Verdana]Sub Macro2()
'
' Macro2 Macro
'<o:p></o:p>[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]'
    ActiveSheet.PivotTables("PivotTable2").PivotFields("date").PivotFilters.Add _
        Type:=xlDateLastWeek
End Sub<o:p></o:p>[/FONT][/COLOR]
<o:p> </o:p>
<o:p> </o:p>
Thanks<o:p></o:p>
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.

Forum statistics

Threads
1,224,502
Messages
6,179,126
Members
452,890
Latest member
Nikhil Ramesh

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