View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
VB Newbie[_2_] VB Newbie[_2_] is offline
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