View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
klysell klysell is offline
external usenet poster
 
Posts: 146
Default Updating pivot items in three pivot tables on one sheet via VBA

Hi,

I have this code that updates pivot items on all three pivot tables which
reside on one sheet. Why doesn't this code work? Below is the code:

Private Sub Worksheet_Change(ByVal Target As Range)

Dim ws, pt, pi, strField blah, blah, blah

strField = "DAC"
On Error Resume Next
If Target.Address = Range("$H$2").Address Then
For Each pt In ws.PivotTables
With pt.PageFields(strField)
For Each pi In .PivotItems
If pi.Value = Target.Value Then
.CurrentPage = Target.Value
Exit For
Else
.CurrentPage = "(All)"
End If
Next pi
End With
Next pt
End If

End Sub


Does anyone have any answers?

Thank-you for your help!
--
Kent Lysell
Financial Consultant
Ottawa, Ontario
W: 613.948-9557