Dear Debra,
Thank You. Thank you for taking the time and your for your response. My
pivot tables use an external database. Your code worked when the data source
is from an excel spreadsheet. However, I could not get it to work for the
external data source.
Michael
--
Newbie trying to learn VBA
"Debra Dalgleish" wrote:
You could use the following code that will match all the page fields,
based on an update to any one of the pivot tables on the same sheet:
'======================================
Private Sub Worksheet_PivotTableUpdate(ByVal Target As PivotTable)
On Error Resume Next
Dim ws 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 ws = ActiveSheet
Set ptMain = Target
Application.EnableEvents = False
Application.ScreenUpdating = False
For Each pfMain In ptMain.PageFields
For Each pt In ws.PivotTables
If pt.Name < ptMain.Name Then
For Each pf In pt.PageFields
If pf.Name = pfMain.Name Then
If pfMain.CurrentPage = "(All)" Then
pf.CurrentPage = "(All)"
Exit For
Else
For Each pi In pf.PivotItems
If pi.Name = pfMain.CurrentPage Then
pf.CurrentPage = pi.Name
Exit For
End If
Next pi
End If
End If
Next pf
End If
Next pt
Next pfMain
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
'===================================
xlMS2SF wrote:
I need help adapting VBA code that I found on Contextures.com
When the end user chooses the two page fields in ptMain, I need it to
automatically enter it in pt2, pt3 and pt4. pt2 is on the same page as
ptMain. All four pivot tables use the same page filter.
Here is code, I just don't know how to adapt.
=================
--
Debra Dalgleish
Contextures
www.contextures.com/tiptech.html
Blog: http://blog.contextures.com