+ Reply to Thread
Results 1 to 1 of 1

Pivot Table VBA Correction

  1. #1
    Registered User
    Join Date
    07-11-2012
    Location
    Massachusetts,US
    MS-Off Ver
    Excel 2010
    Posts
    44

    Pivot Table VBA Correction

    Please help I really need this!
    Hello so I found this amazing VBA for pivot tables but I need to change something on the VBA to make it work for me. I found the VBA on Youtube http://www.youtube.com/watch?v=3CGLi7t1lDE.
    This is the VBA code it self. So what it does it changes all the pivot tables when I change the information on one of them. But I want to make it so it only changes the categories I change. Right now if I change for example the date in one it will change it in all of them, but lets say I have a category of people and each table I have set a different person if I change the date in one of the pivot tables the person will also change in every pivot table to be the same as in the one I changed the date in. To get a better understanding of the VBA code and what it does go to the site. Thank You!



    Option Explicit
    Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
    On Error Resume Next
    Dim wsMain As Worksheet
    Dim ws As Worksheet
    Dim ptMain As PivotTable
    Dim pt As PivotTable
    Dim pfMain As PivotField
    Dim pf As PivotField
    Dim pi As PivotItem
    Dim bMI As Boolean

    On Error Resume Next
    Set wsMain = ActiveSheet
    Set ptMain = Target

    Application.EnableEvents = False
    Application.ScreenUpdating = False

    For Each pfMain In ptMain.PageFields
    bMI = pfMain.EnableMultiplePageItems
    For Each ws In ThisWorkbook.Worksheets
    For Each pt In ws.PivotTables
    If ws.Name & "_" & pt <> wsMain.Name & "_" & ptMain Then
    pt.ManualUpdate = True
    Set pf = pt.PivotFields(pfMain.Name)
    bMI = pfMain.EnableMultiplePageItems
    With pf
    .ClearAllFilters
    Select Case bMI
    Case False
    .CurrentPage = pfMain.CurrentPage.Value
    Case True
    .CurrentPage = "(All)"
    For Each pi In pfMain.PivotItems
    .PivotItems(pi.Name).Visible = pi.Visible
    Next pi
    .EnableMultiplePageItems = bMI
    End Select
    End With
    bMI = False

    Set pf = Nothing
    pt.ManualUpdate = False
    End If
    Next pt
    Next ws
    Next pfMain

    Application.EnableEvents = True
    Application.ScreenUpdating = True

    End Sub
    Last edited by gjergji; 10-10-2012 at 05:09 PM.

+ 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