View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default How do I unprotect/with password to run marco and protect

Your other post said you got it working????

J_Will wrote:

Didn't work. Don't give up on me. I'll hold out until tonigh. If I can't
figure it out, I'll send with out my button.

"Rookie 1st class" wrote:

Try adapting these to meet your needs:

Private Sub Workbook_Open()
' Perform this when workbook opened.
' Macro recorded 06/15/00 by Lou Mullen
Worksheets("Recall").Select
Application.ActiveWorkbook.Protect Password:="YourCode"
range("A1").Select
ActiveSheet.Unprotect
Selection.Sort Key1:=range("A1"), Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
ActiveSheet.Protect
Application.CommandBars("Recall Macros").Visible = True
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
'Perform steps on exit Macros
'Macro recorded 06/15/00 by Lou Mullen
Application.EnableCancelKey = xlDisabled
If Application.CommandBars("Recall Macros").Enabled = True Then
If Application.CommandBars("Recall Macros").Visible = True Then
Application.CommandBars("Recall Macros").Visible = False
End If
Application.ActiveWorkbook.Unprotect Password:="YourCode"
Application.CommandBars("Recall Macros").Delete
Else
Application.CommandBars("Recall Macros").Enabled = False
Application.ActiveWorkbook.Unprotect Password:=YourCode"
End If
End Sub

HTH Lou

"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