Sorting with worksheet protected

  • Thread starter Thread starter Donna Brooks
  • Start date Start date
D

Donna Brooks

I need to be able to sort my data, but my worksheet is
protected. I know that with the Protect method, you can
use "AllowSorting", but all the cells in the sheet must
be unlocked. I'm trying to put Sort Acs & Sort Desc
buttons on my worksheet. This is the code in the
Ascending.
ActiveCell.Range("A1:AW104").Sort Key1:=ActiveCell.Offset
(0, 0).Range("A1"), _
Order1:=xlAscending, Header:=xlGuess,
OrderCustom:=1, MatchCase:=False _
, Orientation:=xlTopToBottom,
DataOption1:=xlSortNormal

But using this code, it sorts the correct column (the
column the cursor is in), but it starts the sort at the
row your cursor is on and that messes the data up. If you
have a fix, please tell me what it is, or is there a way
to just unlock right before sorting.

Thanks in advance,
Donna Brooks
 
I'm not sure that this is the best way to do it, but what
I did to get around this is pretty simple.

At the point you want protection off put in:

activesheet.unprotect

and where you want it reprotected (you guessed it):

activesheet.protect

Hope this helps.

KG
 
Back
Top