My problem is arising with an Excel 2000 pivot table. (It started life in Excel 97 but I am trying to work with it in 2000).
We have a field dimensioned as a page field - Manager.
This has values say: Fred Bloggs, John Smith, Prince Harry, ...
My boss who I prepared this pivot table for wants to see what the data would look like without the part of our empire managed by John Smith. So he double clicks on the Manager field and selects John Smith to hide him.
The next day he comes to me and says the pivot table is not working because it does not tie up with data from another source. After investigation, we track down that he has hidden a manager and forgotten.
Foolishly, perhaps, I volunteered that I could probably write a VBA procedure that would unhide all such items.
Now if I record the unhiding I get:
With ActiveSheet.PivotTables("PivotTable1".PivotFields("Manager"
.PivotItems("John Smith".Visible = True
End With
The good news is it works. The bad news is it takes about a second per manager using a 600 mhz PC if I loop through all the managers. There are maybe 30 managers. The really bad news is that in addition there are a dozen other fields such a DIVISION, PERIOD, ACCOUNTANT,... and some of these might have a hundred items in them. So basically my simple code is not much good unless a PC magazine wants a nice slow benchmark.
Plan B - Excel help has an example that looks very attractive along the lines of:
For each pvtItem in pvtTable.PivotFields("Manager".HiddenItems
' some action here
Next pvtItem
The trouble is that it does not work. Basically, most items are coming up in the HiddenItems collection even if they have not been hidden. At the very least just having a Page Field set to All seems to make everything hidden.
Has anyone got ideas as to how I can make this work?
Ken
We have a field dimensioned as a page field - Manager.
This has values say: Fred Bloggs, John Smith, Prince Harry, ...
My boss who I prepared this pivot table for wants to see what the data would look like without the part of our empire managed by John Smith. So he double clicks on the Manager field and selects John Smith to hide him.
The next day he comes to me and says the pivot table is not working because it does not tie up with data from another source. After investigation, we track down that he has hidden a manager and forgotten.
Foolishly, perhaps, I volunteered that I could probably write a VBA procedure that would unhide all such items.
Now if I record the unhiding I get:
With ActiveSheet.PivotTables("PivotTable1".PivotFields("Manager"
.PivotItems("John Smith".Visible = True
End With
The good news is it works. The bad news is it takes about a second per manager using a 600 mhz PC if I loop through all the managers. There are maybe 30 managers. The really bad news is that in addition there are a dozen other fields such a DIVISION, PERIOD, ACCOUNTANT,... and some of these might have a hundred items in them. So basically my simple code is not much good unless a PC magazine wants a nice slow benchmark.
Plan B - Excel help has an example that looks very attractive along the lines of:
For each pvtItem in pvtTable.PivotFields("Manager".HiddenItems
' some action here
Next pvtItem
The trouble is that it does not work. Basically, most items are coming up in the HiddenItems collection even if they have not been hidden. At the very least just having a Page Field set to All seems to make everything hidden.
Has anyone got ideas as to how I can make this work?
Ken