View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Sorting a protected worksheet

The obvious choice would be to unprotect and reprotect the worksheet

Activesheet.unprotect Password:="ABCD"
Range(Cells(56, 2), Cells(rw, 2)).Select
Selection.Sort Key1:=Range("B56"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Activesheet.Protect Password:="ABCD"

You can also look at the UserInterfaceOnly property of the Protect method if
you are leary about unprotecting the sheet for the sort.

--
Regards,
Tom Ogilvy


"Vince" wrote in message
...
I am using the following code to sort, and it works fine as long as the

worksheet is not protected. When the worksheet is protected, I get the
error 1004 Sort method of range class failed. I have made sure the cells
that are being sorted are not protected, but I still get the error after I
protect the worksheet. Any help would be appreciated.

Range(Cells(56, 2), Cells(rw, 2)).Select
Selection.Sort Key1:=Range("B56"), Order1:=xlAscending,

Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

Thank you,
Vince