I am having a small issue with macro that is suppose to unprotect my worksheet, refresh Pivot Table and protect ws again (with condition). It works OK only partially as it does unprotect the ws, it refreshes the Pivot Table, but after that something strange is happening: - it doesn't really restore back rows and columns formatting - it doesn't protect the ws back properly (my ws looks like it is protected when you click on Tools,Protection - but, you can unprotect it without entering password again ??!!
Sub RefreshPivotTables()
' will remove password and refresh PT
Dim xpt As PivotTable
With ActiveSheet
.Unprotect Password:="milessss"
For Each xpt In Worksheets("WT-1").PivotTables
xpt.RefreshTable
Next xpt
.Protect Password:="milessss", AllowFormattingCells:=True, _
AllowFormattingRows:=True, AllowFormattingColumns:=True, _
AllowUsingPivotTables:=True, EnableOutlining:=True
End With
End Sub
Can anybody help please ? Cheers - Mile`S