View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
J_Will J_Will is offline
external usenet poster
 
Posts: 6
Default How do I unprotect/with password to run marco and protect

Oaky, I fixed the Syntax error - I THINK IT WORKED!!!!!!

"Dave Peterson" wrote:

Sub sort_of()
'
' sort_of Macro
' Macro recorded 2/10/2006 by Julianne
'

'
ActiveSheet.Unprotect password:="sandy crotch"
Range("A16").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Sort Key1:=Range("AF16"), Order1:=xlDescending, _
Header:=xlGuess _
, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("A16").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, _
Scenarios:=True, password:="sandy crotch"
End Sub

J_Will wrote:

Password = "sandy crotch"

Can you put it into my macro, below, so I can cut and paste? So it
unprotecteds the sheet (sandy crotch) and password protects it (sandy crotch)

Sub sort_of()
'
' sort_of Macro
' Macro recorded 2/10/2006 by Julianne
'

'
ActiveSheet.Unprotect
Range("A16").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Sort Key1:=Range("AF16"), Order1:=xlDescending,
Header:=xlGuess _
, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
Range("A16").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub

"Dave Peterson" wrote:

option explicit
sub yourmacro()
activesheet.unprotect password:="topsecret"
'your sort code here
activesheet.protect password:="topsecret"
end sub



J_Will wrote:

I have a locked sheet with columns unlocked for users to populate. I have it
protected with a password so users can only update certain cells. I wrote a
macro to sort data when entries are completed by clicking a button. How can
I unprotect it with password, run macro, and protect it with password after
sort is complete

--

Dave Peterson


--

Dave Peterson