karolina1406
Board Regular
- Joined
- Apr 18, 2016
- Messages
- 110
- Office Version
- 365
- Platform
- Windows
I am refreshing the table query on a protected sheet. I use below code that works fine however, as soon as I add one more command to protect sheets back - i get Run time error 91: object variable or With block variable not set
Any ideas why??
VBA Code:
Dim wSheet As Worksheet
For Each wSheet In Worksheets
wSheet.Unprotect Password:="password"
Next wSheet
Application.ScreenUpdating = False
Sheets("Available_Stock").ListObjects(1).QueryTable.Refresh BackgroundQuery:=False
Any ideas why??