Excel Pivot Table VB Code

G

Guest

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!
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top