Protect/Unprotect Sheet from Macro

N

Nigel

Hi All
I have a worksheet that in large part has locked cells, the sheet is then
protected. This of course disables sort. What I am trying to do is
unprotect the sheet, do the sort and then protect the sheet. I have not as
yet added a password.

If I do the above manually from the UI, all is OK, but the macro that
follows fails on the sort method. The sheet is showing unprotected. Problem
in both xl97 and xl2002.

ActiveSheet.Unprotect

Selection.Sort Key1:=Range("B5"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

TIA
Cheers
Nigel
 
N

Nigel

Sorry everyone - stupid mistake - its nothing to do with protection the sort
method relies on a selection that I excluded.

Cheers
Nigel
 
Top