+ Reply to Thread
Results 1 to 12 of 12

Remove ability to filter Pivot Table

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    01-18-2010
    Location
    Bentley, NM
    MS-Off Ver
    Excel 2010
    Posts
    229

    Remove ability to filter Pivot Table

    I have some code that enables me to remove a lot of the pivot table functionality and it works fairly well, but I also want it to remove the ability to filter on any column. My goal is to basically keep the pivot table formatting and data without allowing any manipulation of the data. I've tried all of the copy/paste special methods I've found online, but none of them truly keep the original formatting.

    Here is the code I use to remove certain user abilities:

    Sub AllowPivotTable()
    'pivot table tutorial by contextures.com
    Dim pt As PivotTable
    Dim pf As PivotField
    Set pt = ActiveSheet.PivotTables(1)
    With pt
    .EnableWizard = False
    .EnableDrilldown = False
    .EnableFieldList = False 'Excel 2002+
    .EnableFieldDialog = False
    .PivotCache.EnableRefresh = False
    End With
    End Sub
    Can I modify this to essentially remove every user ability, so that they can only see the data? For now, I think removing the ability to filter is the most important.

  2. #2
    Forum Contributor
    Join Date
    01-18-2010
    Location
    Bentley, NM
    MS-Off Ver
    Excel 2010
    Posts
    229

    Re: Remove ability to filter Pivot Table

    I'm looking at using the Protect Sheet function and just do it that way. My only concern is that the user can copy and paste the sheet elsewhere and then have access to the data? I was able to open a blank workbook and copy the sheet to it then I had total control over the pivot table. I will test it with other people in my department to see if it's the same.

  3. #3
    Forum Contributor
    Join Date
    01-18-2010
    Location
    Bentley, NM
    MS-Off Ver
    Excel 2010
    Posts
    229

    Re: Remove ability to filter Pivot Table

    My requirements have changed a bit since the last post. Now, I would like for users to be able to use Slicers on the pivot table - and possibly expand/collapse - but have no access to anything else. Is this possible?

    Thanks.

  4. #4
    Valued Forum Contributor
    Join Date
    01-03-2016
    Location
    Conwy, Wales
    MS-Off Ver
    2016
    Posts
    974

    Re: Remove ability to filter Pivot Table

    I have also read your related post http://www.excelforum.com/excel-gene...le-access.html.

    What are your concerns?
    - are you concerned about the security of the data?
    (ie it must not be capable of being copied)

    - are you concerned that users having access to the data may create their own pivot tables that are incomplete/inaccurate
    (ie the data is complicated and multifaceted and it is all too easy for the user to make a mistakes when filtering, resulting in "misleading" reports)

    - are you concerned that users are likely to"damage" the pivot table itself or the data or both?
    (ie - the integrity of the workbook, pivot tables, underlying data, formula etc is at stake)

  5. #5
    Forum Contributor
    Join Date
    01-18-2010
    Location
    Bentley, NM
    MS-Off Ver
    Excel 2010
    Posts
    229

    Re: Remove ability to filter Pivot Table

    Quote Originally Posted by Kevin# View Post
    I have also read your related post http://www.excelforum.com/excel-gene...le-access.html.

    What are your concerns?
    - are you concerned about the security of the data?
    (ie it must not be capable of being copied)

    - are you concerned that users having access to the data may create their own pivot tables that are incomplete/inaccurate
    (ie the data is complicated and multifaceted and it is all too easy for the user to make a mistakes when filtering, resulting in "misleading" reports)

    - are you concerned that users are likely to"damage" the pivot table itself or the data or both?
    (ie - the integrity of the workbook, pivot tables, underlying data, formula etc is at stake)
    Kevin - I am concerned with everything you mentioned. Security being less important. Once they have the data they can show it to anyone they like, but I do not want them to be able to manipulate what I send them in the Pivot Table. If I had to choose between allowing them to copy the pivot table and implementing my other requirements, I would choose to allow them to copy the data.

    Ideally, I would have one master Pivot table containing all of the data. I would then filter it for the relevant user, and send them the result. They would be able to then filter and expand/collapse, but they would not have access to the underlying data for the other users. Alternatively, I would create a separate Workbook for each user that only contains their data. this would alleviate the concern about viewing other users' data. They would still be able to filter with slicers and expand/collapse, but they could not alter the fields, change calculated fields, or otherwise change the data in ANY way.

    This may be difficult to visualize without an example workbook, but I'm trying to remain theoretical for now if possible.

  6. #6
    Valued Forum Contributor
    Join Date
    01-03-2016
    Location
    Conwy, Wales
    MS-Off Ver
    2016
    Posts
    974

    Re: Remove ability to filter Pivot Table

    I am happy to discuss it all theoretically, for the moment - I probably should not be trusted with your data either LOL
    I will deal with all your concerns separately and give you suggestions to tackle each one, after gaining an understanding of scale.

    Let's always strike a sensible balance between control and practicality:
    Must make a realistic assessment of the time\effort required to "button things down" measured against the risk if that is not done.
    And let's avoid users ending up so hamstrung (and possibly annoyed that they are not trusted) that they go back to the source (ie you) with endless minor requests - which would be a real pain.

    Firstly let's consider (quickly, I hope) creating and distributing individual reports:
    you have Managers1,2,3 etc who each have a number of staff A,B,C,D,E ...Z reporting to them

    Q1 - Assuming that you could easily create individually tailored reports, how many "individual" variations of each report would there need to be? 10+, 50+, 100+
    Q2 Would some of these reports be grouped reports for managers? eg Manager1 gets consolidated table ( = Staff A+B+C+D+ E) Manager2 gets a similar report (=staff F+G+H+I +J + some extra data) etc
    Q3 How many different types of report are there?
    Q4 How often are they produced? Weekly? Monthly?
    Q5 Would it be practical/sensible to deal with all those spreadsheets?

  7. #7
    Forum Contributor
    Join Date
    01-18-2010
    Location
    Bentley, NM
    MS-Off Ver
    Excel 2010
    Posts
    229

    Re: Remove ability to filter Pivot Table

    Quote Originally Posted by Kevin# View Post
    I am happy to discuss it all theoretically, for the moment - I probably should not be trusted with your data either LOL
    I will deal with all your concerns separately and give you suggestions to tackle each one, after gaining an understanding of scale.

    Let's always strike a sensible balance between control and practicality:
    Must make a realistic assessment of the time\effort required to "button things down" measured against the risk if that is not done.
    And let's avoid users ending up so hamstrung (and possibly annoyed that they are not trusted) that they go back to the source (ie you) with endless minor requests - which would be a real pain.

    Firstly let's consider (quickly, I hope) creating and distributing individual reports:
    you have Managers1,2,3 etc who each have a number of staff A,B,C,D,E ...Z reporting to them

    Q1 - Assuming that you could easily create individually tailored reports, how many "individual" variations of each report would there need to be? 10+, 50+, 100+
    One for each Manager - ~15
    Q2 Would some of these reports be grouped reports for managers? eg Manager1 gets consolidated table ( = Staff A+B+C+D+ E) Manager2 gets a similar report (=staff F+G+H+I +J + some extra data) etc
    Each Manager would only see their staff members. All else equal between managers. Each Manager should be able to view an individual staff, a group of staff, total for all staff, or any other combo therein.
    Q3 How many different types of report are there?
    For the moment, one report, but we all know that won't last. Automating the creation and distribution of the reports in Excel would be ideal.
    Q4 How often are they produced? Weekly? Monthly?
    Monthly
    Q5 Would it be practical/sensible to deal with all those spreadsheets?
    Unfortunately, my decisions can't always be guided by practicality...
    Have a look at my answers above. As you can see for question 5, whether or not this request is practical does not necessarily matter at the moment.

  8. #8
    Valued Forum Contributor
    Join Date
    01-03-2016
    Location
    Conwy, Wales
    MS-Off Ver
    2016
    Posts
    974

    Re: Remove ability to filter Pivot Table

    Thanks,
    the numbers small enough to make individual reports easily manageable, if other ways of concealing the data do not appeal (we will get onto that soon, I promise...)

    To close out the "individual report" discussion:
    Q6 If you were to create ~15 individual reports would there be any overlap or unallocated gap in the "total"
    (In other words does Rpt1 + Rpt2 + Rpt3 ...................................Rpt15 = PivotTableTotal)
    Q7 How stable are the Manager's staff groupings?
    (do staff hop between Managers (or Managers hop between staff groups), and if so does their (historic) data follow them)
    Q8 Why do Managers only see their own staff's data? Confidentiality or to reduce distractions?
    Q9 How would you make the reports available?
    - allow managers to run "their" report off your intranet OR
    - email separate monthly workbooks to managers

  9. #9
    Forum Contributor
    Join Date
    01-18-2010
    Location
    Bentley, NM
    MS-Off Ver
    Excel 2010
    Posts
    229

    Re: Remove ability to filter Pivot Table

    Wow, I feel like I'm working with a paid consultant ! I didn't bother using colored fonts for my responses this time. Too complicated.

    Quote Originally Posted by Kevin# View Post
    Thanks,
    the numbers small enough to make individual reports easily manageable, if other ways of concealing the data do not appeal (we will get onto that soon, I promise...)

    To close out the "individual report" discussion:
    Q6 If you were to create ~15 individual reports would there be any overlap or unallocated gap in the "total"
    (In other words does Rpt1 + Rpt2 + Rpt3 ...................................Rpt15 = PivotTableTotal)
    Nothing would be unallocated.
    Q7 How stable are the Manager's staff groupings?
    (do staff hop between Managers (or Managers hop between staff groups), and if so does their (historic) data follow them)
    They should be static, but there are instances where that could change. The historic data stays with the Manager.
    Q8 Why do Managers only see their own staff's data? Confidentiality or to reduce distractions?
    Confidentiality
    Q9 How would you make the reports available?
    - allow managers to run "their" report off your intranet OR
    - email separate monthly workbooks to managers
    For now, it's looking like a monthly email solution.

  10. #10
    Valued Forum Contributor
    Join Date
    01-03-2016
    Location
    Conwy, Wales
    MS-Off Ver
    2016
    Posts
    974

    Re: Remove ability to filter Pivot Table

    Final (one big) question (for the moment) - I want a feel for the volume of data

    It makes no difference what's contained in the data, just want to appreciate what will happen if we "split the atom"

    Q10 Is all master data contained in one single long worksheet? (I presume it must be)
    Q11 Is there a separate line for each month for each strand of data?
    Q12 How many months' data is to be provided to each Manager in his Pivot Report?
    Q13 Is there more than one strand of data for each employee (eg separate products, or split areas etc) - if so how many?
    Q14 Are you tracking actuals only, or are there budgets/forecasts included?
    Q15 Roughly how many columns and rows of data are there in the master table?
    Q16 Is the data growing or are you looking at roughly the same amount of cumulative data each month? (ie moving the view along a month at a time)
    Q17 What is the FileSize of that (master data) workbook now?

    From everything you've said so far, the simplest solution could well be to create separate monthy worksheets for each manager. But (and this is dependant on the size of the data table) we may be able to keep everything in one file and not let everyone see everything.

    Before deciding anything let's consider what else we could do to restrict access to some of the data by examining (in post#11) some of the excellent access controls available within Excel.

  11. #11
    Valued Forum Contributor
    Join Date
    01-03-2016
    Location
    Conwy, Wales
    MS-Off Ver
    2016
    Posts
    974

    Re: Remove ability to filter Pivot Table

    Try these 2 files for size. Open and allow macros

    The files are identical except for their name
    Currently the files are set to autosave when closed (temporary while still working on it)

    Each file contains
    - sheet("Data") - with all the data (set to VeryHidden)
    - sheet("myData") - into which an individual manager's data is copied (set to VeryHidden)
    - sheet("myPivot) - which contains the manager's own pivot table based on his "myData" (set to VeryHidden at time of opening)

    When the files are opened
    - only blank Sheet1 is visible AND
    - a password is required (captured in a text box)

    The files have different passwords (both have upper case first letter)
    file "mike..." = Hisword
    file "sueb..." = Herword

    When the password has been entered, the code checks to see if "1st 4 chars of filename" + "password" matches pre-designated string.

    If the string matches
    - sheet myPivot is unhidden
    - pivot table is immediately updated with managers data
    - manager's data set is based on cell "A1" value which is currently = "1st 4 characters of file name"

    In the example files the 2 managers' pivot includes details for different staff

    At the moment this is not bomb proof (otherwises becomes a pain to work on) - need to protect the vba etc and prevent user saving changes etc.

    I believe this goes a long way towards meeting your needs
    - you may prefer (for data security reasons) to piecemeal the actual data rather than putting "all" in each

    Let me know what you think and then I will tell you how to amend it to test it out on your own data



    this is how a managers selections are grouped:
    Manager = Sheets("myPivot").Range("A1").Value
    Select Case UCase(Manager)
    
    Case "MIKE"
            With Sheets("Data")
            Range(.Range("A1"), .Range("A1").SpecialCells(xlLastCell)).AutoFilter Field:=3, Criteria1:="=Joe", _
            Operator:=xlOr, Criteria2:="=Peter"
            End With
    Case "SUEB"
            With Sheets("Data")
            Range(.Range("A1"), .Range("A1").SpecialCells(xlLastCell)).AutoFilter Field:=3, Criteria1:="=David", _
            Operator:=xlOr, Criteria2:="=John"
            End With
    this is how the the selected data is copied into sheet myData and the pivot table refreshed
    Sub CopyDataToMyData()
    Sheets("data").Visible = True
    
    Dim ws1 As Worksheet, ws2 As Worksheet, ws3 As Worksheet
    Dim rPivot As Range
    Dim Manager As String
    Set ws1 = Sheets("Data")
    Set ws2 = Sheets("myData")
    Set ws3 = Sheets("myPivot")
    
    'clears old pivot data area and replace with latest data
    ws2.Cells.ClearContents
    ws1.UsedRange.SpecialCells(xlCellTypeVisible).Copy Destination:=ws2.Range("a1")
    
    'refresh the pivot table using latest data
    Set rPivot = Range(ws2.Range("A1"), ws2.Range("A1").SpecialCells(xlLastCell))
    ws3.PivotTables("MyPivot").ChangePivotCache ThisWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:=rPivot)
    ws3.PivotTables("MyPivot").RefreshTable
    Call HideSheets
    ws3.Range("A1").Select
    this is the password control when the file is opened (driven via textbox on UserForm which is presented as the file opens)
    Private Sub CommandButton1_Click()
    Dim x As String
    y = UCase(Left(ThisWorkbook.Name, 4))
    x = TextBox1.Value
    Select Case y & x
        Case "MIKEHisword"
        GoTo Approved
    End Select
    Select Case y & x
        Case "SUEBHerword"
        GoTo Approved
    End Select
     
    Rejected:
    MsgBox "User/Password mismatch"
    Exit Sub
    
    Approved:
    Sheets("myPivot").Visible = True
    Sheets("Sheet1").Visible = False
    UserForm1.Hide
    Sheets("myPivot").Select
    Sheets("myPivot").Range("A1").Value = y 'manager's name
    Call Manager
    Call CopyDataToMyData
    
    End Sub
    Attached Files Attached Files
    Last edited by Kevin#; 01-13-2016 at 07:57 AM. Reason: attempt to manually add code

  12. #12
    Forum Contributor
    Join Date
    01-18-2010
    Location
    Bentley, NM
    MS-Off Ver
    Excel 2010
    Posts
    229

    Re: Remove ability to filter Pivot Table

    Quote Originally Posted by Kevin# View Post
    Final (one big) question (for the moment) - I want a feel for the volume of data

    It makes no difference what's contained in the data, just want to appreciate what will happen if we "split the atom"

    Q10 Is all master data contained in one single long worksheet? (I presume it must be)
    Yes, that's the goal instead of having a worksheet for each clinic.
    Q11 Is there a separate line for each month for each strand of data?
    Yes, and potentially it will go even deeper (more granular).
    Q12 How many months' data is to be provided to each Manager in his Pivot Report?
    Still toying with that - maximum of twelve
    Q13 Is there more than one strand of data for each employee (eg separate products, or split areas etc) - if so how many?
    Yes, this will change, but for now we can say 2.
    Q14 Are you tracking actuals only, or are there budgets/forecasts included?
    Actuals only for the time being
    Q15 Roughly how many columns and rows of data are there in the master table?
    ~8000 rows for one full year. 10 columns
    Q16 Is the data growing or are you looking at roughly the same amount of cumulative data each month? (ie moving the view along a month at a time)
    the data will grow each monthly update
    Q17 What is the FileSize of that (master data) workbook now?
    nothing to be scared of...1MB or less.
    From everything you've said so far, the simplest solution could well be to create separate monthy worksheets for each manager. But (and this is dependant on the size of the data table) we may be able to keep everything in one file and not let everyone see everything.

    Before deciding anything let's consider what else we could do to restrict access to some of the data by examining (in post#11) some of the excellent access controls available within Excel.
    Thanks again for the detailed response. Definitely want to keep everything in one file if possible and then limit access. I'm working on something similar for another project of mine with the goal being some VBA that will filter each pivot table on each sheet by the Manager, save to the Manager's file directory, filter each pivot table by the next Manager, save to his directory and so on until complete. I've found code that will iterate through the Manager filter for the pivot tables, but I don't know if I'm able to scale that to multiple pivot tables on multiple sheets. I don't think it would be too difficult for someone well versed in VBA - which is not me.

    Edit - I will take a look at your worksheets when I can. Thanks again!
    Last edited by maw230; 01-13-2016 at 04:09 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 01-29-2015, 07:13 PM
  2. Replies: 5
    Last Post: 10-14-2014, 09:47 AM
  3. Replies: 6
    Last Post: 07-31-2014, 12:56 PM
  4. [SOLVED] Remove drop down filter from Pivot Table
    By ZuneidDassu in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 02-26-2014, 04:41 AM
  5. Pivot table, assigning a cell wo be change the Pivot table filter
    By jwongsf in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-28-2012, 05:00 PM
  6. How to remove 0 from excel pivot table filter using macro
    By deep_blr in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-15-2012, 06:37 AM
  7. Change Pivot table Filter Based on Cell Value *Multiple Filter items* Possible?
    By Flydd in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-27-2012, 06:57 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1