VB Script for Excel Refreshall Pivot Tables

Dbllt02

New Member
Joined
Jun 22, 2011
Messages
1
Hello,
I've run into some issues with my VB scripting. I'm a novice VB user so any help here would be welcomed. My code is below. Basically I open one excel workbook and have the VB script open, update, and close other workbooks. I cannot get the refreshall command to work correctly. The workbook has 10 sheets with multiple pivot tables on each sheet which pull data from an Access database. The refreshall updates all the pivot tables except the ones on the first, third, and fourth sheets, it's basically skipping those three sheets altogether.

Sub auto_open()

'Start code

Application.DisplayAlerts = False

Cells.Select
Selection.Copy
ActiveSheet.Next.Select
Range("A1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("A1").Select
ActiveSheet.Previous.Select
Range("A1").Select

'Run_All_PivotTables()<~~~~~THis is where the problems begin

Application.Wait Now + TimeValue("00:00:5")

Application.Workbooks.Open ("X:\Planning & Analysis\Reporting\FlashReports\US\FlashReport_StoreLevel_Data_CTP_US.xlsm")

ActiveWorkbook.RefreshAll

Application.Wait Now + TimeValue("00:10:00")

ActiveWorkbook.Save

Application.quit

Application.Wait Now + TimeValue("00:00:5")

Application.Workbooks.Open ("X:\Planning & Analysis\Reporting\FlashReports\US\ACHClearance_Store.xlsm")

ActiveWorkbook.RefreshAll

Application.Wait Now + TimeValue("00:10:00")

ActiveWorkbook.Save

Application.quit

End Sub

Any help is greatly appreciated!

Thanks
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Hello and welcome to The Board.
My understanding is that Refreshall in VBA will use the settings that appear in the 'external data' settings.
If it is set to 'background refresh' then you are allowing 10 minutes for that to take place - is that long enough? It is worth checking - if it is ticked, I would try unticking the 'background refresh' and then remove the 'wait'.
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,334
Members
452,907
Latest member
Roland Deschain

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top