Spreadsheet 123 Excel 2003, XP, 2000, 97 FAQs: Auto Refresh

Automatically refresh pivot table when data in a sheet changes in Excel 2003/XP/2000/97

Question:  I'm looking for a macro that would automatically refresh a pivot table whenever data is changed in an Excel worksheet. Is this possible?


Answer:  There are several "events" available within an Excel spreadsheet where you can place VBA code. In your case, we want to refresh the pivot table when the "Worksheet_Calculate" event fires.


Let's take a look at an example.


Download Excel spreadsheet (as demonstrated below)




In our spreadsheet, there are two sheets - one is called Data which contains the source data for the pivot table. Another sheet is called Pivot which contains the pivot table.


On the sheet called Data, we've placed code on the "Worksheet_Calculate" event, so that whenever the data changes on the "Data" sheet, the pivot table will be refreshed.


You can press Alt-F11 to view the VBA code.


Note: This only will work, if you have the spreadsheet set to calculate "automatically". This is the default for most Excel spreadsheets, but some people turn this feature off.

Macro Code:

The macro code looks like this:

Private Sub Worksheet_Calculate()


    'If data on this worksheet changes, refresh the pivot table
    Sheets("Pivot").PivotTables("PivotTable1").RefreshTable


End Sub

Suggested Reading

Spreadsheet News



Forum


Meet advanced users of MS Excel and Spreadsheet and do not be shy to ask your question.


Book Shop


Visit our busy book shop, were you can find latest books for beginners as well as advanced users of excel and similar programs.



Software Library




Excel & Spreadsheet Online Tutorials




Spreadsheet123
Home | About Us | Our Services | Software | Excel Templates | Excel Tutorials | Useful Links | Site Map | Contact Us
Bookmark this PageBookmark this Page

Link To Us
Home
About Us

Book Shop

Excel
Excel Tutorials
Financial Modeling
Excel Templates

Excel Tutorials

Excel Basic Tutorial
Excel Tech on Net
MS Excel Tutorials and Projects
MS Excel Spreadsheet Tutorial
How to Decide What Chart Type to Use
How To Merge Cells in Excel
Excel - Printing Effectively from Excel
Using Excel Functions and Creating Formulas

Excel Templates

Corporate finance spreadsheets
Valuation Inputs Spreadsheets
Big-picture valuation spreadsheets
Focused valuation spreadsheets
Financial Service firms
Troubled firms
Private companies
Young and high-growth firms
Multiples
Valuation in Acquisitions
Valuation of other assets
Value Enhancement Spreadsheets
Basic option pricing models
Real option models in corporate finance
Real option models in valuation
Hotel & Restaurant Management Spreadsheets
Real Estate & Mortgage Excel Spreadsheets
Excel Personal Budget Spreadsheets
More Spreadsheets

Software Library

Accounting Software
Small Business Software
Tax Calculating Software
Auditing Software
Excel Add-Ins
Property Management Software
Payroll Software
Spreadsheet Software

Contact Us
Useful Links
Our Services
Site Map