I have a document that functions (using many already written and functioning Macros) to essentially stand as a visual representation of a calendar, which can then be exported to a powerpoint graphic. Because of the way this process is conducted, it is essential that empty rows are kept between each data row. I wrote my own sort and filter functions to preserve this condition while giving the user proper functionality, and now am working on document security.
Thus, the primary question I have (although this can be spread more generally to all worksheet actions) is whether or not it is possible to restrict users from ever using the default Sort functions from excel (as this would immediately destroy the data structure)?
To clarify, the sheet already has protect and unprotect functionality, but I need the AllowSorting
property to remain false even when the sheet is unprotected. Is this possible?
Edit:
I attempted to solve the issue by not unprotecting the sheets, but instead protecting them with all protections "off" with the exception of the AllowSorting and AllowFiltering properties, which remain false in both the Locked and Unlocked configurations. However, this still allowed me to sort data when the sheets were "unlocked"
Edit 2: Since further explanation seems necessary, I already have Macros that protect and unprotect the sheet accordingly. I need to be able to give FULL functionality to any user who has the correct password, with the exception of sorting, as no user should ever use the sort functions. My code for these functions is shown (abbreviated) below:
Sub LockSheets()
For Each WS In ActiveWorkbook.Worksheets
WS.Protect Password:=MasterPass, _
DrawingObjects:=True, _
Contents:=True, _
Scenarios:=True, _
AllowFormattingCells:=False, _
AllowFormattingColumns:=False, _
AllowFormattingRows:=False, _
AllowInsertingColumns:=False, _
AllowInsertingRows:=False, _
AllowInsertingHyperlinks:=False, _
AllowDeletingColumns:=False, _
AllowDeletingRows:=False, _
AllowSorting:=False, _
AllowFiltering:=False, _
AllowUsingPivotTables:=False
Next WS
End Sub
Sub UnlockSheets()
For Each WS In ActiveWorkbook.Worksheets
WS.Protect Password:=MasterPass, _
DrawingObjects:=False, _
Contents:=False, _
Scenarios:=False, _
AllowFormattingCells:=True, _
AllowFormattingColumns:=True, _
AllowFormattingRows:=True, _
AllowInsertingColumns:=True, _
AllowInsertingRows:=True, _
AllowInsertingHyperlinks:=True, _
AllowDeletingColumns:=True, _
AllowDeletingRows:=True, _
AllowSorting:=False, _
AllowFiltering:=False, _
AllowUsingPivotTables:=False
Next WS
End Sub