RefreshAll Method of Workbook Object VBA

RefreshAll Workbook method in VBA is used to refreshes all data ranges and available pivot table reports in the specified workbook.



50+ Project Management Templates Pack
Excel PowerPoint Word

Advanced Project Plan & Portfolio Template
Excel Template

Business Presentations Templates Pack
PowerPoint Slides

20+ Excel Project Management Pack
Excel Templates

20+ PowerPoint Project Management Pack
PowerPoint Templates

10+ MS Word Project Management Pack
Word Templates

Why we use RefreshAll Workbook method in VBA?

We use ‘RefreshAll’ Workbook method in VBA to refreshes data ranges and pivot table reorts in the mentioned workbook.

VBA RefreshAll Workbook Method – Syntax

Here is the syntax to RefreshAll workbook method using VBA.

Workbooks(“Your Workbook Name”).RefreshAll

In the above syntax Workbook represents object and RefreshAll represents the method of workbook object.

VBA RefreshAll Workbook Method:Example 1

Please find the below example, It will show you how to do refresh entire active workbook.

Sub Workbook_RefreshAll()
End Sub

VBA RefreshAll Workbook:Example 2

Here is the one more example, it will refreshes the specific workbook.

Sub Workbook_RefreshAll()
End Sub

VBA RefreshAll Workbook: Example 3

Here is the one more example, it will refreshes the second workbook.

Sub Workbook_RefreshAll2()
End Sub

VBA RefreshAll Workbook: Pivot Tables

Here is the one more example, it will refreshes all pivot tables which are available in active sheet of the workbook.

Sub Workbook_PivotTables()
Dim pvtTbl As pivotTable
For Each pvtTbl In ActiveSheet.PivotTables
End Sub

VBA RefreshAll Workbook Method- Instructions

Please follow the below step by step instructions to execute the above mentioned VBA macros or codes:

  1. Open an Excel Workbook
  2. Press Alt+F11 to Open VBA Editor
  3. Insert a Module from Insert Menu
  4. Copy the above code for activating a range and Paste in the code window(VBA Editor)
  5. Save the file as macro enabled workbook
  6. Press ‘F5’ to run it or Keep Pressing ‘F8’ to debug the code line by line.


  1. Steve February 16, 2016 at 2:52 PM - Reply

    I have a pivot table that uses an table as its data source. In turn, the table acting as the data source is linked to a table in an access database.

    If I use ActiveWorkbook.RefreshAll I know both the table and the pivot table will be refreshed but is there anyway that I can ensure that the data source table is refreshed before the pivot table that relies on it?

    • Caleb May 18, 2016 at 6:00 PM - Reply

      Best option is to put the ActiveWorkbook.RefreshAll code line at least twice, so you ensure it doesn’t matter the order for data updates in the related tables.


  2. eric March 11, 2016 at 3:54 PM - Reply

    When I open a worksheet data are updated from an external database. after that the pivottables in the worksheet should be refreshed. I have the vba code to refresh the pivottables but the macro for refreshing the pivottables is starting directly by opening the worksheet so before the data are updated.
    What is the vba code to refresh the pivottables starting after the data are updated?

Leave A Comment

Related pages

excel password sheethow can i find duplicates in exceldelete duplicate excellookup on excelvba tutorial excel 2007sql questions asked in interviewvlookup excel exampleexcel vba enddeleting duplicates in exceldeveloping macros in excelexcel 2010 remove duplicatesexcel vba select a rangeexample of vba codevba select a workbookhow to unlock excel workbookvariables vbaddl example sqlexcel macro file locationfreshers interview questions and answers technicalexcel combine tabshow to change row to column in excelvlookup examples in excelexcel if statements examplesexcel charvba toolmatch function excelvba close excelexcel vba activeworkbook.saveasexcel macro rename fileuserform excel vbaaccess close form vbavba excel arraysvba sortingexcel replace in formulaautofit in excelexcel uppercaseexcel color index valueshelpful excel formulasxls macro tutorialexcel schedule plannersumif function in excel 2010how do you unshare a workbookdefine merging cellsapplication in vbaddl dml commands in sqlinterview questions on sql queries with answers pdfexcel combine tables from multiple sheetsexcel filter out duplicatesexcel vba listobjectsms access export to excel vbait project budget template excelvisual basic checkboxvba find value in rangeexcel task scheduler templatevba filtershow to use iserror with vlookupproject timeline gantt chart templateexcel spreadsheet dashboard templatesexcel vba call subinserting multiple rows in excelexcel datevaluevba saveashow to calculate time difference between two dates in excelexcel 2007 delete blank rowscountif function in excel 2007vba hyperlink addressformula of hlookupexcel remove repeatsexcel if isblank thenmacro password removerhow to adjust width of column in excelexcel mergecellsexcel 2010 vba editorbasic excel tests for interviewsproject plan template word docvisual basic check boxsendmail attachment examplevba excel celluse of vlookup in excel 2007 with exampleadvanced filter excel 2013