Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Unprotect question.

In response to a recent posting, JulieD helped out someone with a script to
unprotect and the protect a worksheet. It works great for me, except for one
thing. When I go up to unprotect the worksheet, it doesn't prompt me for a
password. I've checked VB help, but still cannot find a solution. Below is
her script and the script I used to incorporate hers. Any help would be
appreciated :)

_JulieD
ThisWorkbook.Worksheets("Sheet1).Unprotect("YourPa ssword")
ThisWorkbook.Worksheets("Sheet1).Protect("YourPass word")

_Mine
Sub unpro_pro()
Range("B2").Select
Worksheets("sheet1").Unprotect Password:="YourPassword"
ActiveCell.FormulaR1C1 = "=R[1]C[4]"
Range("B2").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Worksheets("sheet1").Protect Password:="YourPassword"
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Unprotect question.

Hi

Instead of this,

Sub unpro_pro()
Range("B2").Select
Worksheets("sheet1").Unprotect Password:="YourPassword"
ActiveCell.FormulaR1C1 = "=R[1]C[4]"
Range("B2").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True,
Scenarios:=True
Worksheets("sheet1").Protect Password:="YourPassword"
End Sub


Try it like this

Sub unpro_pro()
Range("B2").Select
Worksheets("sheet1").Unprotect Password:="YourPassword"
ActiveCell.FormulaR1C1 = "=R[1]C[4]"
Range("B2").Select
Worksheets("sheet1").Protect Password:="YourPassword",
DrawingObjects:=True, Contents:=True, Scenarios:=True

End Sub

I didn't check the Protect syntax for the order of the items following
protect, but it seemed to work for me.

HTH

Ken


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Unprotect question.

To explain, basically when you tried to protect the sheet with a password,
the line before had already protected the sheet with no password. Hence no
password box if you clicked tools, unprotect sheet, because there was no
password.

Ken


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Unprotect question.

Problem fixed! Thanks so much, Ken!
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 77
Default Unprotect question.

You are welcome

Ken


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
Unprotect in a macro Partly Void[_2_] Excel Discussion (Misc queries) 3 October 5th 08 10:45 AM
Unprotect a worksheet FRAZZLED New Users to Excel 0 May 30th 06 05:06 PM
Unprotect worksheet via VBA Mike Echo Excel Worksheet Functions 2 March 19th 06 04:52 AM
Unprotect Conditional Formatting Excel Discussion (Misc queries) 3 September 5th 05 02:49 PM
Unprotect workbook Jean-Paul De Winter Excel Programming 4 October 17th 04 09:00 AM


All times are GMT +1. The time now is 11:24 AM.

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"