Need help with additing additional parameters for VBA code

crossfire266

New Member
Joined
May 12, 2019
Messages
2
Hi everyone!

Hoping to get some help with the following issue..

I have the VBA code (below) which will protect and unlock grouping options for a excel sheet, however I would like to add the option for user to edit/add cells, use filter options too .. pretty much get all the functionality in a protect sheet ticked out.

Can anyone assist me with this on letting me know where I should add the code to allow the extra functionality for a protected sheet?

Current code:

Sub Workbook_Open()
'Update 20140603
Dim xWs As Worksheet
Set xWs = Application.ActiveSheet
Dim xPws As String
xPws = "225" ''Application.InputBox("Password:", xTitleId, "", Type:=2)
xWs.Protect Password:=xPws, Userinterfaceonly:=True
xWs.EnableOutlining = True
End Sub

Thanks in advance,
Jo
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Try this

Code:
Sub Workbook_Open()
    'Update 20140603
    Dim xWs As Worksheet
    Set xWs = Application.ActiveSheet
    Dim xPws As String
    xPws = "225" ''Application.InputBox("Password:", xTitleId, "", Type:=2)
    xWs.Protect Password:=xPws, _
        DrawingObjects:=False, Contents:=True, _
        Scenarios:=False, Userinterfaceonly:=True, _
        AllowFormattingCells:=True, AllowFormattingColumns:=True, _
        AllowFormattingRows:=True, AllowInsertingColumns:=True, _
        AllowInsertingRows:=True, AllowInsertingHyperlinks:=True, _
        AllowDeletingColumns:=True, AllowDeletingRows:=True, _
        AllowSorting:=True, AllowFiltering:=True, _
        AllowUsingPivotTables:=True
    
    xWs.EnableOutlining = True
End Sub
 
Upvote 0
Legend this worked!

Much Appreciated ;)!

Try this

Code:
Sub Workbook_Open()
    'Update 20140603
    Dim xWs As Worksheet
    Set xWs = Application.ActiveSheet
    Dim xPws As String
    xPws = "225" ''Application.InputBox("Password:", xTitleId, "", Type:=2)
    xWs.Protect Password:=xPws, _
        DrawingObjects:=False, Contents:=True, _
        Scenarios:=False, Userinterfaceonly:=True, _
        AllowFormattingCells:=True, AllowFormattingColumns:=True, _
        AllowFormattingRows:=True, AllowInsertingColumns:=True, _
        AllowInsertingRows:=True, AllowInsertingHyperlinks:=True, _
        AllowDeletingColumns:=True, AllowDeletingRows:=True, _
        AllowSorting:=True, AllowFiltering:=True, _
        AllowUsingPivotTables:=True
    
    xWs.EnableOutlining = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,566
Messages
6,120,262
Members
448,953
Latest member
Dutchie_1

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