"Results Thru xx/xx/xxx" Report Heading - Obtain max date from PivotItems

xmarine1973

New Member
Joined
Sep 11, 2014
Messages
1
I need to create a report heading that says "Includes YTD sales thru xx/xx/xxxx." I would like to write a VBA which dynamically assigns the maximum sales date that was located within a pivot table field (PivotItem list). Notice that I didn't say that I want to change the filter... I only want to use the max date to change the heading at the top of the report.

I've already been through many forums and development websites which explain how to filter the report by the max date. Howevver, I am not looking to alter any of the PivotFields and I'd prefer to leave the filters alone (leave everything set to "All"). Instead, I am only wanting the VBA script to examine one specific field called "activity_date" and then identify the maximum date found. Finally, it should insert this max date into my report heading. Putting all of the dates into the "row labels" is quite messy since there are so many dates in my pivot table so I would prefer not to do this.

For example: Let's say that my pivot table ("PivotTable20") was refreshed today and the "activity_date" filter now ranges between 1/1/2013 to 9/10/2014. I just want the VBA to cycle through all dates to identify the maximum date within that PivotField without altering the filters. After the maximum date has been found, it should update the report heading to say: "Includes YTD sales thru 9/10/2014." When I refresh the report again tomorrow, it should change dynamically to "Includes YTD sales thru 9/11/2014" (since an additional sales day was just recorded).

This sounds so simple. But does anybody have any thoughts on how it could be done?
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce

Forum statistics

Threads
1,214,787
Messages
6,121,569
Members
449,038
Latest member
Guest1337

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