View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.newusers
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default How do I sort a proctected worksheet

Be specific about the range to sort--exclude the columns that should not be
sorted from the range to be sorted.

The range to sort must be contiguous, though.

dim wks as worksheet
dim rng as range
set wks = worksheets("Protected")
with wks
.unprotect password:="Hi"
set rng = .range("d3:g" & .cells(.rows.count,"D").end(xlup).row)

with rng
.sort key1:=.columns(3), order1:=xlascending, header:=true
end with
.protect password:="Hi"
end with

===
Untested and uncompiled--watch for typos.

I sorted D3:G (lastrow in column D). and avoided all the other cells.


Audrey wrote:

That is a given, but I have columns that I don't want sorted.

I have locked those columns in hopes they would not sort and the others would.

Any suggestions?

Thanks for the help.

"Chip Pearson" wrote:

Unprotect it.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"Audrey" wrote in message
...





--

Dave Peterson