Protect Worksheets per user

joferder

Board Regular
Joined
Dec 18, 2005
Messages
59
We use Office 365 at work and have documents that are uploaded to Sharepoint. I have some users that would like to protect their worksheets and workbooks, but have other users that need to be able to make changes to certain parts of the spreadsheet. I have searched far and wide and cannot find if this option is even available (I keep getting information on how to protect a worksheet or workbook, which I know how to do). Mostly it would be a few people with master control, but one user would have edit access to one specific tab.

Any help would be greatly appreciated on this one. It is the last thing that really keeps them from being happy with the switch from Google Sheets.
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
You could give something like this a try. Essentially, when an "unauthorized" user...in this case "Bob" tries to edit column L. It returns a messagebox followed by an "Undo" command. This script would be placed in the sheet where the protected range is.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

 If Not Intersect(Target, Sheet4.Range("L:L")) Is Nothing Then
    If Environ("UserName") = "Bob" Then
        Application.EnableEvents = False
        MsgBox "You do not have permissions to modify this range"
        Application.Undo
        Application.EnableEvents = True
    End If
 End If
 End Sub
 
Upvote 0
Solution
You could give something like this a try. Essentially, when an "unauthorized" user...in this case "Bob" tries to edit column L. It returns a messagebox followed by an "Undo" command. This script would be placed in the sheet where the protected range is.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

 If Not Intersect(Target, Sheet4.Range("L:L")) Is Nothing Then
    If Environ("UserName") = "Bob" Then
        Application.EnableEvents = False
        MsgBox "You do not have permissions to modify this range"
        Application.Undo
        Application.EnableEvents = True
    End If
 End If
 End Sub
Thank you for taking the time to write all of that up. I was hoping for a slightly simpler solution for our users who are not super tech savvy. I think they will just need to get used to the fact that the permissions work a little different in Office than they did in Google Sheets. It definitely wasn't a deal breaker for them.

Thanks again for your help.
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,219
Members
452,620
Latest member
dsubash

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