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:
|
Visit our busy book shop, were you can find latest books for beginners as well as advanced excel users.
Spreadsheet 123 Spreadsheet Software Development
See Spreadsheets for:
a.Hotel Management b.Personal Budget
c.Corporate Finance d.Rating Calculation e.Real Estate and Mortgage
f.Web Calc