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 !
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 !
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.
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
Add this to the code
![]()
Sheets("SheetName").Protect userinterfaceonly:=True
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
Put the statements in the other order
![]()
Private Sub Worksheet_Activate() Sheets("Zoekfuncties").Protect userinterfaceonly:=True Sheets("Zoekfuncties").PivotTables("Draaitabel1").PivotCache.Refresh End Sub
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.
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
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
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
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
hello,
it works !!
you are the best, i'm very happy!!
thank you!!!!
I learned something too!![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks