Consulting

Results 1 to 4 of 4

Thread: Solved: Data sort in a protected workbook

  1. #1

    Solved: Data sort in a protected workbook

    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?

    [vba]
    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
    [/vba]

  2. #2
    Moderator VBAX Master geekgirlau's Avatar
    Joined
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,464
    Location
    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.

  3. #3
    I discovered that AllowSorting is also available in Excell 2002. Problem solved!! Thanks very much.

  4. #4
    As a matter of interest, Geekgirlau, when you add AllowSorting in the global protect code, the range to be sorted can be left protected.

Posting Permissions

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