ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Excel Pivot Table VB Code (https://www.excelbanter.com/excel-discussion-misc-queries/69871-excel-pivot-table-vbulletin-code.html)

carolini

Excel Pivot Table VB Code
 
Hi,

I currently have a Pivot Table report that shows data in rolling 12 months
(12/2004 to 11/2005). Once I refresh the data I get 13 months (12/2004 to
12/2005)and then I go into each pivot and click off the earliest month
(12/2004).

Can anyone help me with a code that would click off the earliest month?

Thanks!

Jonathan Cooper

Excel Pivot Table VB Code
 
assuming your dates are NOT entered as text, and that youyou could insert a
helper column with the following formula.

=IF(DATE(YEAR(TODAY()),MONTH(TODAY())+1,0)-DATE(YEAR(A4),MONTH(A4)+1,0)<365,"show","hide")

A4 is the cell in your data table, that contains the date you are using. I
did it this way because I wasn't sure if you were consistently using month
end dates or not.

Now, add this helper column to your pivot table, and then use this field as
your page feild.

"carolini" wrote:

Hi,

I currently have a Pivot Table report that shows data in rolling 12 months
(12/2004 to 11/2005). Once I refresh the data I get 13 months (12/2004 to
12/2005)and then I go into each pivot and click off the earliest month
(12/2004).

Can anyone help me with a code that would click off the earliest month?

Thanks!



All times are GMT +1. The time now is 02:48 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com