Problem in code for protect sheets

Solved/Closed
SARC Posts 29 Registration date Saturday August 7, 2010 Status Member Last seen August 31, 2010 - Aug 17, 2010 at 11:08 PM
SARC Posts 29 Registration date Saturday August 7, 2010 Status Member Last seen August 31, 2010 - Aug 18, 2010 at 05:32 AM
Hello..

how can i make this code to have a password to unprotect the sheet.. but i dont want to be entering the password each time i make a change to the worksheet



[CODE]inputWks.Unprotect
historyWks.Unprotect

lRec = inputWks.Range("CurrRec").Value
lRecRow = lRec + 1

With inputWks
Set myRng = .Range(myCopy)

If Application.CountA(myRng) <> myRng.Cells.Count Then
MsgBox "Please fill in all the cells!"
Exit Sub
End If
End With

With historyWks
With .Cells(lRecRow, "A")
.Value = Now
.NumberFormat = "mm/dd/yyyy hh:mm:ss"
End With
.Cells(lRecRow, "B").Value = Application.UserName
oCol = 3
For Each myCell In myRng.Cells
historyWks.Cells(lRecRow, oCol).Value = myCell.Value
oCol = oCol + 1
Next myCell
End With

'clear input cells that contain constants
With inputWks
On Error Resume Next
With .Range(myCopy).Cells.SpecialCells(xlCellTypeConstants)
.ClearContents
Application.GoTo .Cells(1) ', Scroll:=True
End With
On Error GoTo 0
End With

inputWks.Protect
historyWks.Protect

End Sub/CODE

Thanks

1 reply

rizvisa1 Posts 4479 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 768
Aug 18, 2010 at 12:12 AM
when you protect or unprotect, pass the password too
0
SARC Posts 29 Registration date Saturday August 7, 2010 Status Member Last seen August 31, 2010
Aug 18, 2010 at 12:48 AM
thanks rizviza,.. but how do i do that??
thanks again
0
rizvisa1 Posts 4479 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 768
Aug 18, 2010 at 05:22 AM
or if there is a password
ActiveSheet.Unprotect ("MyPassWord")


To protect back
ActiveSheet.Protect ("MyPassWord")
0
SARC Posts 29 Registration date Saturday August 7, 2010 Status Member Last seen August 31, 2010
Aug 18, 2010 at 05:32 AM
thanks rizvi i got it to work.. thanks.........
0