Hi All,
Very new to the forums here and would like to say hello with a somewhat complicated question.
The previous guy at my job has created a very large spreadsheet containing data in multiple pivot tables (about 45-50 tables in total). Users of the spreadsheet needs to go through all these tables when they only need to change one thing (i.e. Company Name) for the data on the dashboard to show properly.
I tried using the code below, thinking that I just need to add pivot tables one by one on the Set part, but got a runtime error instead.
Any help would be greatly appreciated! Thank you!
Very new to the forums here and would like to say hello with a somewhat complicated question.
The previous guy at my job has created a very large spreadsheet containing data in multiple pivot tables (about 45-50 tables in total). Users of the spreadsheet needs to go through all these tables when they only need to change one thing (i.e. Company Name) for the data on the dashboard to show properly.
I tried using the code below, thinking that I just need to add pivot tables one by one on the Set part, but got a runtime error instead.
Any help would be greatly appreciated! Thank you!
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Target, Range("O6:O7")) Is Nothing Then Exit Sub
Dim pt As PivotTable
Dim Field As PivotField
Dim NewCat As String
Set pt = Worksheets("Sheet4").PivotTables("PivotTable8")
Set Field = pt.PivotFields("Company Code")
NewCat = Worksheets("Sheet1").Range("O6").Value
With pt
Field.ClearAllFilters
Field.CurrentPage = NewCat
pt.RefreshTable
End With
End Sub