Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Greetings. I have created a PivotTable using VBA and connecting to a
SQL database. The Pivot is created fine, but I cannot refresh the PivotTable. I cannot simply delete the Pivot or the sheet each time I need to update the data either, but I cannot figure out what code to write to KEEP the option to Refresh the data. Basically all I have is a PivotTable with a snapshot in time of the data and it doesn't help me because I need to refresh the data often. Does anyone have any thoughts? I've been struggling on this one for a while and I'm getting close to deadlines on some items. Thanks in advance for any help Paul |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Paul,
I haven't seen any response to your request so I found the followin code in Google. It appears to be what you ar looking for you may hav to modify it. If this helps the credit goes to the ones who create it. HTH Charles Sub RefreshTables() vArr = Array( _ "M:\Data Dir\Project1\MyProject1.xls", _ "M:\Data Dir\Project1\MyProject2.xls", _ "M:\Other Dir\Invoices\MyInvoice.xls", _ "P:\Shared1\SubDir1\SubDir2\Myworbkook.xls") for i = 1 to ubound(vArr) set wkbk = Workbooks.Open varr(i) for each sh in wkbk.Worksheets for each pt in sh.PivotTables pt.PivotCache.BackgroundQuery = False Next Next wkbk.RefreshAll wkbk.Close SaveChanges:=True Next End Su -- Message posted from http://www.ExcelForum.com |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How can I 'Enable Automatic Refresh' for Query Refresh by default | Setting up and Configuration of Excel | |||
'Enable Automatic Refresh?' | Setting up and Configuration of Excel | |||
enable automatic refresh | Excel Worksheet Functions | |||
Enable Automatic Refresh | Excel Worksheet Functions | |||
Query Refresh-Enable Automatic Refresh Dialogue Box | Excel Discussion (Misc queries) |