Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Vj Vj is offline
external usenet poster
 
Posts: 54
Default Refresh Pivot Tables

Hi

Is there any way I can automatically open and unprotect , refresh and then
protect a Pivot table through VBA macro?

Pls help me out.

Thanks in advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Refresh Pivot Tables

Use the
Activesheet.EnablePivotTable
Activesheet.Protect Password:="ABC", UserInterfaceOnly:=True
Activesheet.PivotTables(1).RefreshTable

This must be done each time the workbook is opened as the EnablePivotTable
and UserInterfaceOnly settings are not persistent across the closing of a
workbook (so use the workbook open event as an example. )

--
Regards,
Tom Ogilvy

"VJ" wrote in message
...
Hi

Is there any way I can automatically open and unprotect , refresh and

then
protect a Pivot table through VBA macro?

Pls help me out.

Thanks in advance.



  #3   Report Post  
Posted to microsoft.public.excel.programming
Vj Vj is offline
external usenet poster
 
Posts: 54
Default Refresh Pivot Tables

Thanks Tom. It works!!!!!!!!


"Tom Ogilvy" wrote:

Use the
Activesheet.EnablePivotTable
Activesheet.Protect Password:="ABC", UserInterfaceOnly:=True
Activesheet.PivotTables(1).RefreshTable

This must be done each time the workbook is opened as the EnablePivotTable
and UserInterfaceOnly settings are not persistent across the closing of a
workbook (so use the workbook open event as an example. )

--
Regards,
Tom Ogilvy

"VJ" wrote in message
...
Hi

Is there any way I can automatically open and unprotect , refresh and

then
protect a Pivot table through VBA macro?

Pls help me out.

Thanks in advance.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Refresh Pivot Tables

I have the same question as VJ, but want the macro to work on any pivot table
by first selecting a cell within that table [I'll do a button nearby each
table to run it] ie similar to the standard ! button.

For me, Tom's code comes out a ActiveSheet.Enable.... [does the Capital S
matter?] and results in error 1004.

I would be similarly grateful for a steer.

"Tom Ogilvy" wrote:

Use the
Activesheet.EnablePivotTable
Activesheet.Protect Password:="ABC", UserInterfaceOnly:=True
Activesheet.PivotTables(1).RefreshTable

This must be done each time the workbook is opened as the EnablePivotTable
and UserInterfaceOnly settings are not persistent across the closing of a
workbook (so use the workbook open event as an example. )

--
Regards,
Tom Ogilvy

"VJ" wrote in message
...
Hi

Is there any way I can automatically open and unprotect , refresh and

then
protect a Pivot table through VBA macro?

Pls help me out.

Thanks in advance.




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Refresh Pivot Tables

VBA is case insensitive for names, variables

Here is a copy of the help example for EnablePivotTable

EnablePivotTable Property Example

This example enables PivotTable controls on a protected worksheet.

ActiveSheet.EnablePivotTable = True
ActiveSheet.Protect contents:=True,
userInterfaceOnly:=True------------------------------------if you have excel
2002 or later, you can set this manually through the sheet protection menu
(under tools) and it will persist as long as it is opened only in xl2002 or
later-- Regards,Tom Ogilvy

"Gordon Humphreys" wrote in
message ...
I have the same question as VJ, but want the macro to work on any pivot
table
by first selecting a cell within that table [I'll do a button nearby each
table to run it] ie similar to the standard ! button.

For me, Tom's code comes out a ActiveSheet.Enable.... [does the Capital S
matter?] and results in error 1004.

I would be similarly grateful for a steer.

"Tom Ogilvy" wrote:

Use the
Activesheet.EnablePivotTable
Activesheet.Protect Password:="ABC", UserInterfaceOnly:=True
Activesheet.PivotTables(1).RefreshTable

This must be done each time the workbook is opened as the
EnablePivotTable
and UserInterfaceOnly settings are not persistent across the closing of a
workbook (so use the workbook open event as an example. )

--
Regards,
Tom Ogilvy

"VJ" wrote in message
...
Hi

Is there any way I can automatically open and unprotect , refresh and

then
protect a Pivot table through VBA macro?

Pls help me out.

Thanks in advance.








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Refresh Pivot Tables

My thanks to Ogilvy et al.
This seems to work fine - select any pivot table first [the separate protect
macros are to keep the password hidden in only one place]

Sub PtRefresher()
Application.Run Range("Unprotecter"
ActiveSheet.EnablePivottable=True
ActiveSheet.Pivottables(1).RefreshTable
MsgBox "Pivot Table Refreshed"
Application.RunRange("Protecter")
End Sub

However, it don't work if a derived PT is on a nearby locked sheet. Is
there any way round? I have recently decided to avoid derived sheets and
always start from scratch: is this the only way?

Is there any way of pasting stuff into these handy messages, for slow typists?



Reply
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
Refresh Pivot Tables with one hit cockatoo Excel Discussion (Misc queries) 3 October 24th 08 05:04 PM
Cannot Refresh Pivot Tables Babs in Ohio Excel Worksheet Functions 0 July 18th 07 02:40 PM
Pivot Tables Refresh Janet BN Excel Discussion (Misc queries) 3 February 12th 07 10:28 PM
Refresh multiple pivot tables Latasha at PBG Excel Discussion (Misc queries) 0 May 2nd 06 04:04 PM
Pivot Tables -- Auto Refresh Aastha Excel Discussion (Misc queries) 1 March 30th 06 08:12 PM


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

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

About Us

"It's about Microsoft Excel"