I have the following code to update all my pivots from one cell ,
Problem i now have is that i do not want to update sheet 5
When i run this code i get an error - if i comment out the uderlined it works fine .
What am i doing wrong ??
Problem i now have is that i do not want to update sheet 5
VBA Code:
Sub UpdatePivottables()
Dim sh As Worksheet
Dim pt As PivotTable
Dim ptField As PivotField
Dim ptItem As PivotItem
Dim pc As PivotCache
For Each sh In ThisWorkbook.Worksheets
[U]If WS.Name <> "Sheet5" Then[/U]
For Each pt In sh.PivotTables
pt.PivotFields("Week").ClearAllFilters
For Each ptItem In pt.PivotFields("Week").PivotItems
If ptItem.Name <> ActiveSheet.Range("C6").Value Then
ptItem.Visible = False
End If
Next ptItem
Next pt
Next sh
End Sub
What am i doing wrong ??