ListObjectsTable_Protection except one column

GUNI

New Member
Joined
Oct 18, 2011
Messages
8
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.


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
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
VBA Code:
Sub AAAProtectAllWorksheets()
    Dim ws As Worksheet
    Dim Pwd As String
    Pwd = InputBox("Enter your password to protect all worksheets", "Protect Worksheets")
    For Each ws In ActiveWorkbook.Worksheets
        
        ws.Range("H1:H1000").Locked = False
        ws.Protect Password:="pwd", UserInterfaceOnly:=True, DrawingObjects:=False, Contents:=True, Scenarios:= _
        True, AllowFiltering:=True, AllowUsingPivotTables:=True

       
    Next ws
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,703
Messages
6,173,983
Members
452,540
Latest member
haasro02

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