+ Reply to Thread
Results 1 to 2 of 2

Pivot tables update with VBA

  1. #1
    Registered User
    Join Date
    07-09-2010
    Location
    Copenhagen, Denmark
    MS-Off Ver
    Excel 2003
    Posts
    1

    Pivot tables update with VBA

    I have a workbook containing of several pivot tables. All the pivot tables get the have the same data source. I have one worksheet called Pivot where i have my main pivot table. When i change the Pagefield in this "Master pivot" it change all the pagefields throughout the workbook.
    I want all the pivot tables to have the same data columns as my "Master pivot", so when i add an extra datafield in the "Master pivot" like Sum of 2010 all the other pivot tables should have this column too.
    I have been able to get the data fields added to the other pivot tables with this code:
    For i = 1 To Sheets("Pivot").PivotTables("PivotTable1").DataFields.count
    Sheets("Energy pivot").PivotTables("PivotTable3").AddDataField Sheets("Energy pivot").PivotTables("PivotTable3").PivotFields(Mid(Sheets("Pivot").PivotTables("PivotTable1").DataFields(i).Name, 8, 6))
    'Several other pivot tables are changed in the same way
    Next
    But there is a problem with that code since it doesnt clear all datafields before it adds the new. I have tried to use .Orientation = xlHidden but i get an error every time

    Can any please help me how to solve this question?

  2. #2
    Registered User
    Join Date
    07-23-2014
    Location
    Manila
    MS-Off Ver
    2010
    Posts
    1

    Re: Pivot tables update with VBA

    use define names and use Offset in the data range:

    =offset(a1,0,0,counta(A:A),counta(1:1))

    then use the defined name as your data source for each pivot table... no need to use a macro....

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1