Sort protected sheet

J

jambun

I have a sheet which has pasted links from another sheet but
consolidates the information, I can sort this information if the sheet
is unprotected, but not if it is protected. I really need to protect
the sheet to stop inadvertently overwriting the pasted link.
I think I can do this by having the Macro unprotect, do the sort and
then reprotect. Is there a way of doing this easier? and is there a
way of stoping anyone of reading a macro which at times is as
important as protecting the data it points to. Thanks EPJ
 
G

Gary Keramidas

just an example.
this protects the sheet, but allows code to run while it's protected.
in the thisworkbook module you could have something like this:

Private Sub Workbook_Open()
Worksheets("Sheet1").Protect UserInterfaceOnly:=True
End Sub

then you could have your sort code like this:

Sub sort()
With Worksheets("Sheet1").Range("A1:C10")
.Sort Key1:=.Range("A2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End With
End Sub


or you could just protect the sheet, then unprotect iwith code, run your sort
code and then protect it again.
 

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