Consulting

Results 1 to 4 of 4

Thread: Disable Sort In Shared Workbook

  1. #1
    VBAX Newbie
    Joined
    Dec 2017
    Posts
    2
    Location

    Disable Sort In Shared Workbook

    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

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Moderator bump.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    VBAX Newbie
    Joined
    Dec 2017
    Posts
    2
    Location
    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.

  4. #4
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    That's my signature. It's at the bottom of every post I make.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •