How do I sort a proctected worksheet

A

Audrey

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.
 
D

Dave Peterson

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.
 

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