+ Reply to Thread
Results 1 to 13 of 13

pivot table automatically refresh

Hybrid View

  1. #1
    Registered User
    Join Date
    02-23-2019
    Location
    Belgium
    MS-Off Ver
    office 2013
    Posts
    9

    pivot table automatically refresh

    I have a pivot table in a secured sheet, is it possible to automatically update that pivot table when a secure tab is opened?

    Thank you !

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,957

    Re: pivot table automatically refresh

    In the work sheet module for the tab you are opening, put the following code and change the sheet name and pivot table name as indicated.
    Private Sub Worksheet_Activate()
    Sheets("SheetNameWithPivot").PivotTables("PivotTableName").PivotCache.Refresh
    End Sub
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Registered User
    Join Date
    02-23-2019
    Location
    Belgium
    MS-Off Ver
    office 2013
    Posts
    9

    Re: pivot table automatically refresh

    Thank you,
    Yes, this works if the tab is not protected, but the tab is protected with password "koss"
    The protection must first be automatically bypassed and then the protection must be reset.
    Is it possible?
    thanks,
    Koen

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,957

    Re: pivot table automatically refresh

    Add this to the code

    Sheets("SheetName").Protect userinterfaceonly:=True

  5. #5
    Registered User
    Join Date
    02-23-2019
    Location
    Belgium
    MS-Off Ver
    office 2013
    Posts
    9

    Re: pivot table automatically refresh

    like this? it doesn't work:
    Private Sub Worksheet_Activate()
    Sheets("Zoekfuncties").PivotTables("Draaitabel1").PivotCache.Refresh
    Sheets("Zoekfuncties").Protect userinterfaceonly:=True
    End Sub

    i'm sorry, I am a beginner who tries something

  6. #6
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,957

    Re: pivot table automatically refresh

    Put the statements in the other order
    Private Sub Worksheet_Activate()
    Sheets("Zoekfuncties").Protect userinterfaceonly:=True
    Sheets("Zoekfuncties").PivotTables("Draaitabel1").PivotCache.Refresh
    End Sub

  7. #7
    Registered User
    Join Date
    02-23-2019
    Location
    Belgium
    MS-Off Ver
    office 2013
    Posts
    9

    Re: pivot table automatically refresh

    ok, thanks, but...
    I get a msgbox where I have to enter the password and the user of the file will not know the password.

  8. #8
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,957

    Re: pivot table automatically refresh

    I should have caught that you were doing this in a worksheet module. You could use ActiveWorksheet instead of naming the sheet. However, explicitly naming the sheet is never wrong and a good habit to get into.

    I had to learn this one myself since I've never done it on a password protected sheet.
    Private Sub Worksheet_Activate()
    Sheets("Zoekfuncties").Protect userinterfaceonly:=True, Password:="Your Password"
    Sheets("Zoekfuncties").PivotTables("Draaitabel1").PivotCache.Refresh
    End Sub

  9. #9
    Registered User
    Join Date
    02-23-2019
    Location
    Belgium
    MS-Off Ver
    office 2013
    Posts
    9

    Re: pivot table automatically refresh

    when I open the secured tab, I get an error message that I can not edit a PivotTable in a secured sheet.
    there is a yellow line in the code:
    Sheets("Zoekfuncties").PivotTables("Draaitabel1").PivotCache.Refresh
    ScreenShot 26-02-2019 -- 20 21 54.jpg

  10. #10
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,957

    Re: pivot table automatically refresh

    I duplicated your exact scenario, according to the articles on line the code is supposed to work.

    Here is an inefficient, but works version of the code
    Private Sub Worksheet_Activate()
    MsgBox "Hello, you have selected the sheet"
    ActiveSheet.Unprotect Password:="Password"
    ActiveSheet.PivotTables(1).PivotCache.Refresh
    ActiveSheet.Protect Password:="Password"
    End Sub

  11. #11
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,957

    Re: pivot table automatically refresh

    I went out to this board with the question and they came up with
    Private Sub Worksheet_Activate()
    ActiveSheet.Protect Password:="koss", userinterfaceonly:=True
    Me.PivotTables("Draaitabel1").RefreshTable
    End Sub

  12. #12
    Registered User
    Join Date
    02-23-2019
    Location
    Belgium
    MS-Off Ver
    office 2013
    Posts
    9

    Thumbs up Re: pivot table automatically refresh

    hello,

    it works !!
    you are the best, i'm very happy!!



    thank you!!!!

  13. #13
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,957

    Re: pivot table automatically refresh

    I learned something too!

+ 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. [SOLVED] VB Code to Refresh Pivot Table Automatically every 5 mins - For Dashboard
    By MarkyP18 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-06-2015, 04:38 PM
  2. How to automatically refresh a pivot table when data changes?
    By JohnJK04 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-31-2015, 08:48 PM
  3. [SOLVED] Pivot table does not refresh automatically.
    By Whitenoise1 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-28-2012, 11:38 AM
  4. Automatically Refresh Pivot Table with new date
    By meyero90 in forum Excel General
    Replies: 9
    Last Post: 08-04-2010, 08:42 AM
  5. Pivot table refresh automatically???/
    By devesh.agrawal in forum Excel General
    Replies: 1
    Last Post: 09-23-2008, 08:34 AM
  6. Refresh Pivot Table Automatically
    By anandmr65 in forum Excel General
    Replies: 1
    Last Post: 07-11-2006, 08:04 AM
  7. Excel 2002 Refresh Pivot Table Automatically
    By ~Dave~ in forum Excel General
    Replies: 2
    Last Post: 07-28-2005, 09:05 AM

Tags for this Thread

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