Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do I unprotect/with password to run marco and protect

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default How do I unprotect/with password to run marco and protect

Try something like

ThisWorkbook.Worksheets("Sheet1").Unprotect Password:="whatever"
' sort
ThisWorkbook.Worksheets("Sheet1").Protect Password:="whatever"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How do I unprotect/with password to run marco and protect

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
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 152
Default How do I unprotect/with password to run marco and protect

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

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

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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How do I unprotect/with password to run marco and protect

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
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default How do I unprotect/with password to run marco and protect

I received a "syntax error". The last line (ActiveSheet.Protect. . .) was
highlighted blue.



"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

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

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

  #9   Report Post  
Posted to microsoft.public.excel.programming
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

  #10   Report Post  
Posted to microsoft.public.excel.programming
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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code to protect/unprotect a sheet using a macro with password FredH Excel Discussion (Misc queries) 5 October 23rd 07 04:49 PM
Macro to protect/unprotect with password Cam Excel Programming 3 July 26th 05 10:36 PM
Please help!!! Using code to password-protect and unprotect... Hawk Excel Programming 6 July 9th 05 10:48 PM
Password - Protect, UnProtect MrAlMackay Excel Programming 5 January 19th 05 07:23 PM
Protect/unprotect sheet with password with VBA? dragontale[_7_] Excel Programming 1 April 19th 04 09:29 PM


All times are GMT +1. The time now is 03:12 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"