ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA Code For Pivot Table. (https://www.excelbanter.com/excel-programming/419016-vba-code-pivot-table.html)

Heera

VBA Code For Pivot Table.
 
Hi,

I am doing a report and the user will have an option to select the
start date from which they want the data.
After creating a pivot table i want to exclude the dates which are not
required.

For example i have data starting from 1-Apr-2008 and the user wants
the report from 5-Apr2008.


Here is the code which will remove the non required dates but this
code will remove only those dates which are mentioned
in the code but the user can select any date after 1-Apr-2008.



With ActiveSheet.PivotTables("PivotTable1").PivotFields ("Audit Date")
.PivotItems("1-Apr-08").Visible = False
.PivotItems("2-Apr-08").Visible = False
.PivotItems("3-Apr-08").Visible = False
.PivotItems("4-Apr-08").Visible = False
End with


Can any one help me with the code which will remove the non required
dates till the start point.

Regards

Heera

Barb Reinhardt

VBA Code For Pivot Table.
 
I've done something similar and decided to put a helper column in to identify
the data I want to use.
--
HTH,
Barb Reinhardt

"Heera" wrote:

Hi,

I am doing a report and the user will have an option to select the
start date from which they want the data.
After creating a pivot table i want to exclude the dates which are not
required.

For example i have data starting from 1-Apr-2008 and the user wants
the report from 5-Apr2008.


Here is the code which will remove the non required dates but this
code will remove only those dates which are mentioned
in the code but the user can select any date after 1-Apr-2008.



With ActiveSheet.PivotTables("PivotTable1").PivotFields ("Audit Date")
.PivotItems("1-Apr-08").Visible = False
.PivotItems("2-Apr-08").Visible = False
.PivotItems("3-Apr-08").Visible = False
.PivotItems("4-Apr-08").Visible = False
End with


Can any one help me with the code which will remove the non required
dates till the start point.

Regards

Heera



All times are GMT +1. The time now is 09:35 AM.

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