A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
You should use the below code. Data sheet you can do onetime protection through Review tab > Protect sheet. VBA code will not be needed for that.
Replace abc with the password of your sheet.
Sub Button5_Click()
ActiveSheet.Unprotect Password:="abc"
ActiveSheet.PivotTables(2).PivotCache.Refresh
ActiveSheet.Protect Password:="abc"
End Sub