View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
ShaneDevenshire ShaneDevenshire is offline
external usenet poster
 
Posts: 2,344
Default Conflicts with autorefresh in pivot table activating sheet protect

Hi,

You can turn protection on with a macro like this

Sub myProtect()
ActiveSheet.Protect Password:="myPassword", UserInterfaceOnly:=True
End Sub

The key here is the UserInterfaceOnly:=True which allows VBA code to execute
against a protected sheet. I haven't tested this with a pivot table but it
should work.


--
Thanks,
Shane Devenshire


" wrote:

I have this code and without the sheet protection works good, but when i
activate the sheet protection it shows me an error, the code is as follows:

Private Sub WorkSheet_Change(ByVal Target As Range)
Sheets("Sheet2").PivotTables(1).PivotCache.refresh
End Sub

is there an option to avoid this error?

regards