ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sorting a protected worksheet (https://www.excelbanter.com/excel-programming/294440-re-sorting-protected-worksheet.html)

Frank Kabel

Sorting a protected worksheet
 
Hi Vince
try
activesheet.unprotect password:="yourpassword"
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:="yourpassword"

--
Regards
Frank Kabel
Frankfurt, Germany


Vince wrote:
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




All times are GMT +1. The time now is 02:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com