Hello all,
In VBA can a pivot table display a PivotItem that does not exist in the data array?
To elaborate further:-
I have a spreadsheet that processes some data, creates a pivot table, and then puts this into a glossy output. The data varies between uses.
It is important that both the PivotItem rows and columns are ordered in my specified order. To do this I am using .PivotItems("x").position = 1, .PivotItems("y").position = 2 etc
If the PivotItem does not exist in the data array I get a run time error (for obvious reasons). Now if i use <On Error Resume Next> the spreadsheet works fine, but my glossy output gets messed up because it is relying on columns in the pivot table that are not there. Alternatively I could crudely program the spreadsheet to insert dummy data to make sure there is always data there to enable the PivotItems to be created.
However I thought there is probably a much more elegant way to deal with this. I have been looking through the library and cant see anything. Does anyone have any ideas?
Many thanks
Andy
Bookmarks