Results 1 to 3 of 3
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    La Jolla, CA
    Posts
    1,468
    Thanks
    30
    Thanked 61 Times in 57 Posts

    Sort protected sheets (2002, 2003)

    (1) I'm not a VBA person; (2) I've searched around and found quite a few bits of VBA code to do this, but can't seem to package any of the bits together to get this working.

    I have a workbook with worksheets, all of which are protected to avoid users changing formulas. I want a macro that I can place as a button on the toolbar that will
    1. realize what the active worksheet is when the macro is run
    2. sort all of the rows (A1:K100, for example -- those are a given and can be hard-wired into the macro) based on column A

    And, retain the protection (very important) throughout.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Sort protected sheets (2002, 2003)

    You can unprotect the worksheet in code, sort it, then reprotect it:

    With ActiveSheet
    .Unprotect
    .Range("A1:K100").Sort Key1:=Range("A1"), Header:=xlYes
    .Protect
    End With

    If you have protected the worksheet with a password, you can add this to both Unprotect and Protect, e.g.

    .Unprotect Password:="TopSecret"

    If you have a different password for each sheet, you will have to determine the password belonging to the active worksheet.

  3. #3
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    La Jolla, CA
    Posts
    1,468
    Thanks
    30
    Thanked 61 Times in 57 Posts

    Re: Sort protected sheets (2002, 2003)

    Thanks. Just tried it and it was perfect. You are ALWAYS right on the money and very clear about your explanations! Much appreciated!

Posting Permissions

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