LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
lee lee is offline
external usenet poster
 
Posts: 184
Default Restrict Pivot Tables

Below is a sample of a pivot table that I'm trying to restrict. Found code
on the web that allows me to do it but I'm having a problem

Sub h_PT_Restrict_PivotTable()
'Restrict pivot table functionality
Dim pf As PivotField
With ActiveSheet.PivotTables(1)
.EnableWizard = False
.EnableDrilldown = False
.EnableFieldList = False 'Excel 2002+
.EnableFieldDialog = False
.PivotCache.EnableRefresh = False
For Each pf In .PivotFields
'If pf.Value = "Data" Then End
With pf
.DragToPage = False
.DragToRow = False
.DragToColumn = False
.DragToData = False
.DragToHide = False
End With
Next pf
End With
End Sub

This works fine until it hits "Data". I can put a watch on it and see it
run through all of the pivot fields. It will run through each field coming
to "Data" last. When the pf value becomes "Data" the macro stops on
..DragToPage = False with an application defined or object defined error.

Any ideas ? I put an If statement (commented out above) that when the pf
value = "Data" then end. This works fine as long as the user doesn't change
"Data" to anything else, if they do then it's back to the same problem.
Should it read "Data" as a pivot field?

Data
TASK ID DESCRIPTION Labor Cost Other Cost
1.1 Base Year Labor $ 131,596 $ 9,527
2.1 Option Period 1 Labor $ 542,806 $ 39,296
3.1 Option Period 2 Labor $ 575,364 $ 41,653
4.1 Option Period 3 Labor $ 610,398 $ 44,189
5.1 Option Period 4 Lalbor $ 647,571 $ 46,880
Grand Total $2,507,735 $ 181,545

--
Lee
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Building pivot tables in Excel 2007 based on existing pivot tables? [email protected] Excel Discussion (Misc queries) 4 December 26th 07 08:05 PM
(Tom?) Pivot tables, code to refer to all pivot tables on template klysell Excel Programming 0 July 20th 07 09:32 PM
How to restrict printing to only completed tables in spreadsheet?. Karen@NS Excel Discussion (Misc queries) 0 June 21st 06 07:49 PM
Restrict pivot table PK Excel Worksheet Functions 1 January 23rd 06 10:09 PM
Pivot tables-controlling user interaction with pivot tables Sindhura Excel Programming 0 August 27th 03 02:10 PM


All times are GMT +1. The time now is 07:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"