Problem in code for protect sheets

Solved/Closed
SARC Posts 29 Registration date Saturday 7 August 2010 Status Member Last seen 31 August 2010 - 17 Aug 2010 à 23:08
SARC Posts 29 Registration date Saturday 7 August 2010 Status Member Last seen 31 August 2010 - 18 Aug 2010 à 05:32
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

Related:

1 response

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


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