Hello,
I am trying to control a pivot table from the dynamic cell value in E2, supervisor name. However, when I run the code below, I get unable to get the PivotFields property of the Pivot Table Class error. At this point, I am unsure what is causing this code. There are no trailing spaces in the field name and as far as I can see there's no error. Please help!
Here's the link to the file: https://drive.google.com/open?id=0Bw...3IzWlpqWVBDZjg
Here's a screenshot of my worksheet. I need A to populate B.
2016-08-09_1022.png
Private Sub Worksheet_SelectionChange(ByVal Target As Range) 'This line stops the worksheet updating on every change, it only updates when cell 'H6 or H7 is touched 'If Intersect(Target, Range("D1")) Is Nothing Then Exit Sub 'Set the Variables to be used Dim pt As PivotTable Dim Field As PivotField Dim NewSupv As String 'Here you amend to suit your data Set pt = Worksheets("Report(Mgr)").PivotTables("IncompCourse") Set Field = pt.PivotFields("Supervisor Name") NewSupv = Worksheets("Report(Mgr)").Range("E2").Value 'This updates and refreshes the PIVOT table With pt Field.ClearAllFilters Field.CurrentPage = NewSupv pt.RefreshTable End With End Sub
Bookmarks