Hi, I have macro to update pivot table when save button is clicked. but the problem is if the macro is not enabled before then the macro does not auto run. is it possible to add another code to the below macro which enables the macros first and the auto runs it.
Thanks
Sushil
Sub update()
With ActiveSheet
.Protect Password:="XXXXXX", UserInterfaceOnly:=True
For Each pt In .PivotTables
pt.RefreshTable
Next pt
End With
End Sub
for auto run in the work book
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
'to run a macro named update
Call Sheet1.update
End Sub
Thanks
Sushil
Sub update()
With ActiveSheet
.Protect Password:="XXXXXX", UserInterfaceOnly:=True
For Each pt In .PivotTables
pt.RefreshTable
Next pt
End With
End Sub
for auto run in the work book
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
'to run a macro named update
Call Sheet1.update
End Sub