View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Gary Keramidas Gary Keramidas is offline
external usenet poster
 
Posts: 2,494
Default Sort protected sheet

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.

--


Gary


wrote in message
...
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