Hello All,
I have been trying write a VBA code for protecting all sheets except the column H. The spreadsheets consists of from ListObjectsTable and slicers. every vba code i have tried locks the slicer.
So i was thinking rather to protect the sheets i could protect the ListObjectsTable except column H. Was wondering if that would be possible.
AllowSlicerCaches:=True - this one i came up not sure if exists.
Thank you for your help.
I have been trying write a VBA code for protecting all sheets except the column H. The spreadsheets consists of from ListObjectsTable and slicers. every vba code i have tried locks the slicer.
So i was thinking rather to protect the sheets i could protect the ListObjectsTable except column H. Was wondering if that would be possible.
AllowSlicerCaches:=True - this one i came up not sure if exists.
Thank you for your help.
VBA Code:
Sub ListObjectsTable_Protection()
Dim tbl As ListObject
Dim sht As Worksheet
Dim pwd As String
pwd = InputBox("Enter your password to protect all worksheets", "Protect Worksheets")
For Each sht In ThisWorkbook.Worksheets
For Each tbl In sht.ListObjects
tbl.ListColumns(6).Range.Select
ActiveSheet.Protection.AllowEditRanges.Add Title:="Range1", Range:=Range(tbl.ListColumns(6).Range.Select), Password:=pwd
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowFiltering:=True, AllowUsingPivotTables:=True, AllowSlicerCaches:=True
Next tbl
Next sht
End Sub