Linked Pivot Table - Multiple Select

bdhogan

New Member
Joined
Oct 28, 2010
Messages
7
Hi all,

Looking for some help here.

I have my VBA code working (thanks to some help from Google!) to link my PivotTables together however for each of the fields I would like to be able to select multiple items in each field. Is this possible?

My code I have produced is attached.

Thanks in advance!

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

On Error Resume Next
Set wsMain = Sheets("Sales Pivot")
Set ptMain = Target

Application.EnableEvents = False
Application.ScreenUpdating = False

For Each pfMain In ptMain.PageFields
    For Each ws In ThisWorkbook.Worksheets
        If ws.Name <> wsMain.Name Then
            For Each pt In ws.PivotTables
                pt.RefreshTable
                For Each pf In pt.PageFields
                    If pf.Name = pfMain.Name Then
                        If pfMain.CurrentPage = "(All)" Then
                            pf.CurrentPage = "(All)"
                            Exit For
                        End If
                        For Each pi In pf.PivotItems
                            If pi.Name = pfMain.CurrentPage Then
                                pf.CurrentPage = pi.Name
                                Exit For
                            End If
                        Next pi
                    End If
                Next pf
            Next pt
        End If
    Next ws
Next pfMain
    
Application.EnableEvents = True
Application.ScreenUpdating = True

End Sub
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Forum statistics

Threads
1,224,561
Messages
6,179,522
Members
452,923
Latest member
JackiG

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top