Sorting a Protected Worksheet

G

Guest

Does anyone know how to allow sorting in a protected worksheet that has
locked cells?
Thanks!
 
G

Gord Dibben

In versions 2002 and greater, if the range of cells to sort is unlocked prior to
adding sheet protection you can sort just that unlocked range.

Elsewise you will have to use VBA to unprotect the sheet, do the sort then
re-protect.

Sub Sort_Protected_Sheet()
ActiveSheet.Unprotect Password:="justme"
Columns("A:E").Select
Selection.Sort Key1:=Range("C2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
ActiveSheet.Protect Password:="justme"
End Sub


Gord Dibben MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top