Problem in code for protect sheets

Solved/Closed
Report
Posts
29
Registration date
Saturday August 7, 2010
Status
Member
Last seen
August 31, 2010
-
Posts
29
Registration date
Saturday August 7, 2010
Status
Member
Last seen
August 31, 2010
-
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

Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
768
when you protect or unprotect, pass the password too
0
Posts
29
Registration date
Saturday August 7, 2010
Status
Member
Last seen
August 31, 2010

thanks rizviza,.. but how do i do that??
thanks again
0
Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
768
or if there is a password
ActiveSheet.Unprotect ("MyPassWord")


To protect back
ActiveSheet.Protect ("MyPassWord")
0
Posts
29
Registration date
Saturday August 7, 2010
Status
Member
Last seen
August 31, 2010

thanks rizvi i got it to work.. thanks.........
0