PDA

View Full Version : Solved: Data sort in a protected workbook



K. Georgiadis
09-27-2006, 11:51 AM
Which of the highlighted lines in the below code is required to permit sorting of a data table when the workbook is under global protection? Is it AllowFiltering:=True?


Public Sub ProtectAll()

Const PWORD As String = "mysecretword"

Dim wsSheet As Worksheet

For Each wsSheet In Worksheets
wsSheet.Protect Password:=PWORD, DrawingObjects:=False, _
Contents:=True, Scenarios:=True, AllowFiltering:=True, _
AllowUsingPivotTables:=True, UserInterfaceOnly:=True, _
AllowFormattingCells:=True, AllowFormattingRows:=True

Next wsSheet

End Sub

geekgirlau
09-27-2006, 11:00 PM
Apparently in Excel 2003 there is a parameter called "AllowSorting" (sorry, I only have v2000 here at work, so can't test it). The notes state "Every cell in the sort range must be unlocked or unprotected", so I'm not sure how well this would cope if you had locked headings - worth a try.

K. Georgiadis
09-28-2006, 05:23 AM
I discovered that AllowSorting is also available in Excell 2002. Problem solved!! Thanks very much.

K. Georgiadis
09-30-2006, 06:32 AM
As a matter of interest, Geekgirlau, when you add AllowSorting in the global protect code, the range to be sorted can be left protected.