Excel 2007 Pivot Charts-- Show last 3 months dynamically

jsolis

New Member
Joined
Oct 5, 2013
Messages
3
I have a pivot chart that displays the last 3 months of data onto a bar graph (eg, Since it is currently October, the graph shows Jul-Sep data). Instead of selecting the desired months manually , I would like to create a macro that will show the desired months every time the calender month changes.

Please refer me to related forums and any help is much appreciated! THANK YOU!!!
 
Last edited:

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.
you could have an extra column within your data set to use as a page filter which limits the data

for example test for the month - 3

lable the column something like - Months to Show

then assuming the date you want to test is starting in Cell B2,

then use
=B2>=DATE(YEAR(TODAY()),MONTH(TODAY())-3,DAY(TODAY()))

copy down the data set
use a table and it will automatically be inserted when you append new data

then use that column in the page filter and say True
 
Upvote 0
no macro , and with a table used as the PT source , it will automatically populate :) - but there maybe a much better way using dynamic ranges - just not sure - so others may still reply with a better idea
 
Upvote 0
I just recently recorded a macro to see what code is being written in the background. I noticed that every time I selected a certain month in my pivot table, this line of code would appear
Code:
With ActiveSheet.PivotTables("PivotTable6").PivotFields("Submit Date")
                 .PivotItems("Nov").Visible = False
                 .PivotItems("Dec").Visible = True
End With


I decided to play around with this line a little bit and was able to select a previous month data by implementing this code.

Code:
With ActiveSheet.PivotTables("PivotTable6").PivotFields("Submit Date")
                 .PivotItems("Nov").Visible = False
                 .PivotItems(Format(DateSerial(Year(Date), Month(Date) - 1, 1), "mmm")).Visible = True
End With
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,875
Members
452,363
Latest member
merico17

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