PDA

View Full Version : Disable Sort In Shared Workbook



Jon_AK
12-14-2017, 12:01 PM
Does anyone have VBA code which will disable sorting of worksheets that are shared on a network to everyone except certain individuals? I have a Excel 2016 workbook with a separate worksheet for each month of the year. The worksheets apply conditional formatting based upon the status of a check box and when someone gets the idea that the worksheet needs to be re-sorted, the sheet gets thrown out of whack and causes me lots of extra work to correct it. All of the cells on the sheets have to be editable for data input. I tried the code pasted below that the a recent post indicated would perform this but when the workbook is in shared mode, it throws errors. I understand that it is not permissable to unprotect a sheet or workbook that is in shared mode but have read there is a workaround to accomplish what I'm trying to do. The below code works fine when not in shared mode.

Private Sub Worksheet_Activate()
Dim WhoCanSort As String
WhoCanSort = ThisWorkbook.WriteReservedBy
If WhoCanSort = "Charlie" Then
ActiveSheet.Unprotect
Else:
ActiveSheet.Protect AllowSorting:=False
End If
End Sub

SamT
12-15-2017, 04:24 PM
Moderator bump.

Jon_AK
12-15-2017, 06:27 PM
I did read through the those relating to posting messages looking for restrictions etc., but thought what I posted was correct... with the exception of an obvious oversight of adding format tags.

SamT
12-16-2017, 06:20 AM
That's my signature. It's at the bottom of every post I make.