ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel 2007 Run-Time error (https://www.excelbanter.com/excel-programming/427006-re-excel-2007-run-time-error.html)

Per Jessen

Excel 2007 Run-Time error
 
Hi

You have to unprotect the sheet before you can refresh the Pivot table.

sub Refresh()

Activesheet.unprotect Password:="JustMe"

'Your code to Refresh to Pivot table

ActiveSheet.Protect Password:="JustMe"
End sub

Hopes this help

---
Per


"Marilyn" skrev i meddelelsen
...
I have a user in my group that created a macro that updates the data based
on
the pivot table. The Pivot table is hidden and the macro runs fine when
the
worksheet is not protected but once he protects the worksheets and tries
to
run the Update macro he gets the "Run-time error 1004;

The code for the macros looks like:
' Update_Form Macro
'

'
Range("V30").Select
ActiveSheet.PivotTables("PivotTable4").PivotCache. Refresh
Range("V46").Select
ActiveSheet.PivotTables("PivotTable2").PivotCache. Refresh

End Sub

Any thoughts why protecting the sheet gives out that error?




All times are GMT +1. The time now is 05:44 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com