Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

pivot tables

ResolvedVersion 2010

Chris has attended:
Excel VBA Introduction course
Excel VBA Intermediate course

Pivot Tables

What's the simplest code available to refresh pivot tables and update the data source?

RE: Pivot Tables

Hi Chris,

Thank you for your question. Below is some code which you can build into an existing macro, which will refresh all pivot tables in your workbook:

Dim Pt As PivotTable

For Each Pt In ActiveSheet.PivotTables

Pt.RefreshTable

Next pt

To update the source data, you could either write or record some code and paste it into the beginning of your Pivot Table macro which copies and pastes the new data into the location of the old data, or you could tell the Pivot Table macro to find the new data in a different sheet by using code similar to the code below:

ActiveWorkbook.Sheets("Sheet_Name").Select

I hope this helps

Kind regards
Marius Barnard
Excel Trainer

Thu 26 Mar 2015: Automatically marked as resolved.

Excel tip:

Bracketed negative numbers

Often Excel users wish to display negative numbers in colour red and bracketed

Intstructions
Step1. Select Format > Cells menu options. Within Numbers tabsheet, select Category = Custom.
Step 2. Select a type such as #,##0;[Red]-#,##0;; that specifies a colour in square brackets.
Step 3. Amend as follows; #,##0;[Red](#,##0;;

Notes: Excel formatting featues are of the form
"Positive; Negative;Zero;Text" separated by semicolon.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.09 secs.