correction in vb code required pivot refresh lock sheet

ateebali

Board Regular
Joined
Dec 13, 2018
Messages
108
Dear Sir,
I am using following code to refresh my pivot table which is on same sheet as of data
The sheet is protected as well since I dont want user to change the format but it is not working on lock sheet, in unlock sheet, its working fine.

Sub Pivot()
'
' Pivot Macro
'


'
ActiveWindow.SmallScroll Down:=24
Range("A37").Select
ActiveSheet.PivotTables("PivotTable2").PivotCache.Refresh
End Sub
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Unprotect your sheet manually and protect it for user but not macro using userinterfaceonly. Change blue to your parameters

Code:
[LEFT][COLOR=#666666][FONT=Lora]Sheets(“[/FONT][/COLOR][COLOR=#0000ff]sheetname[/COLOR][COLOR=#666666][FONT=Lora]”).Protect Password:="[/FONT][/COLOR][COLOR=#0000ff]Secret[/COLOR][COLOR=#666666][FONT=Lora]", UserInterFaceOnly:=True[/FONT][/COLOR][/LEFT]

else (but more complicated)
Code:
[FONT=Lora][COLOR=#666666]Sheets(“[/COLOR][/FONT][COLOR=#0000ff][COLOR=#0000ff][FONT=Verdana]sheetname[/FONT][/COLOR][/COLOR][COLOR=#666666][COLOR=#666666][FONT=Verdana][FONT=Lora]”).unprotect[/FONT][/FONT][/COLOR][/COLOR]

[COLOR=#008000]'Your code[/COLOR]

[LEFT][COLOR=#222222][FONT=Lora][COLOR=#666666]Sheets(“[/COLOR][/FONT][/COLOR][COLOR=#0000ff][COLOR=#0000ff][FONT=Verdana]sheetname[/FONT][/COLOR][/COLOR][COLOR=#666666][COLOR=#666666][FONT=Verdana][FONT=Lora]”).Protect[/FONT][/FONT][/COLOR][/COLOR]
[/LEFT]
 
Last edited:
Upvote 0
Sir not working, can you please send complete coding so I just need to paste them, currently I do like this which is not workable;



Sub Pivot()


Sheets(“Software”).Unprotect
'0


' Pivot Macro
'


'
ActiveWindow.SmallScroll Down:=30
Range("A37").Select
ActiveSheet.PivotTables("Summary").PivotCache.Refresh





Sheets(“Software”).Protect
'


End Sub
 
Upvote 0
Or if there is a way that pivot automatically refreshed
or if we have a formula to consolidate the data like pivot do?
 
Upvote 0
Or if there is a way that pivot automatically refreshed
Unprotect your sheet, then right click the sheet name and click view code. Now paste

Code:
Private Sub Worksheet_Activate()
ActiveSheet.Protect Password:="[COLOR=#0000ff]Secret[/COLOR]", UserInterFaceOnly:=True
ActiveWorkbook.RefreshAll
End Sub

Everytime you want to refresh the pivot, leave the sheet and come back (it will also protect the sheet).
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,942
Messages
6,122,366
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top