Hi All,
I have been working on a project for nearly 2-4 months. I have completed the project and it is working perfectly (VBA Report). I have over 8000 lines of code so you could say I know a bit about VBA. I have done alot of other programs too.
Now to the matter in hand. I know how to select pivot items using vba and have already got this.
However can you select a pivot item which is not there but will be in the future. I have created this report to last a few good years but cannot atm because of this. (Now I have noticed that if it does not find the pivot item, it creates it. Leaving the actual pivot item to resolve to number two. For example say I select Q1 2014 using vba. When it does not find it, it creates Q1 2014. As soon as that data is available it puts it as Q1 20142 as a entity with Q1 2014 already exists but with no data) This is my main issue.
My report uses pivots alot I must be able to select dynamic pivot items and if not what is the solution?
Please find the code below.
'I use this to select data
Sheets("Q1 Open").Select
ActiveSheet.PivotTables("PivotTable1").PivotFields("Date").ClearAllFilters
ActiveSheet.PivotTables("PivotTable1").PivotFields("Date").CurrentPage = _
"(Blank)"
ActiveSheet.PivotTables("PivotTable1").PivotFields("Date").CurrentPage = _
"Q1 2014"
'-----------------------------------------------------------------------------------
'this is another technique to select multiple items
Sheets("Win Rate").Select
With ActiveSheet.PivotTables("PivotTable2").PivotFields("Quarter Win/Loss date")
On Error Resume Next
.PivotItems("Q1 2014").Visible = True
.PivotItems("Q2 2014").Visible = True
.PivotItems("Q3 2014").Visible = True
.PivotItems("Q4 2014").Visible = True
.PivotItems("(blank)").Visible = True
End With
I have been working on a project for nearly 2-4 months. I have completed the project and it is working perfectly (VBA Report). I have over 8000 lines of code so you could say I know a bit about VBA. I have done alot of other programs too.
Now to the matter in hand. I know how to select pivot items using vba and have already got this.
However can you select a pivot item which is not there but will be in the future. I have created this report to last a few good years but cannot atm because of this. (Now I have noticed that if it does not find the pivot item, it creates it. Leaving the actual pivot item to resolve to number two. For example say I select Q1 2014 using vba. When it does not find it, it creates Q1 2014. As soon as that data is available it puts it as Q1 20142 as a entity with Q1 2014 already exists but with no data) This is my main issue.
My report uses pivots alot I must be able to select dynamic pivot items and if not what is the solution?
Please find the code below.
'I use this to select data
Sheets("Q1 Open").Select
ActiveSheet.PivotTables("PivotTable1").PivotFields("Date").ClearAllFilters
ActiveSheet.PivotTables("PivotTable1").PivotFields("Date").CurrentPage = _
"(Blank)"
ActiveSheet.PivotTables("PivotTable1").PivotFields("Date").CurrentPage = _
"Q1 2014"
'-----------------------------------------------------------------------------------
'this is another technique to select multiple items
Sheets("Win Rate").Select
With ActiveSheet.PivotTables("PivotTable2").PivotFields("Quarter Win/Loss date")
On Error Resume Next
.PivotItems("Q1 2014").Visible = True
.PivotItems("Q2 2014").Visible = True
.PivotItems("Q3 2014").Visible = True
.PivotItems("Q4 2014").Visible = True
.PivotItems("(blank)").Visible = True
End With