View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
SNM SNM is offline
external usenet poster
 
Posts: 5
Default How can I edit a protected cell to enter a value manually andthen protect it again (automatically)

Hi,

Thanks so much for your help. I tried it out but two lines of the
code appear in red and show some compilation error. As a result it
wasn't working. Can you please check this.
__________
If MsgBox("Do you want to edit cell" & ECell.Address(False, False) &
"?", vbYesNo) = vbNo Then Exit
Sub
____________

Thanks
SNM

On Feb 4, 9:51 pm, "Bernie Deitrick" <deitbe @ consumer dot org
wrote:
SNM,

Insert a new worksheet into your workbook, and name it Record Sheet. InCellA1 enter "Date and
Time", in B1 enter "User Name", and in C1 enter "Manually entered Value".

Copy the code below, right-click the sheet tab with thecellthat you want to be able toedit,
select "View Code" and paste the code into the window that appears. Change the address to thecell
that you want to overwrite - in the code it is currently C4, set with the code line

Set ECell = Range("C4")

As written, this will only work with onecell, but can be modified to include many cells, if
desired.

Make sure that all the cells are locked, the sheet is passwordprotected, and.... give it a try.
The record sheet will include the date/time, the username, and the value entered into thecell.

HTH,
Bernie
MS Excel MVP

Option Explicit
Public myPW As String
Public GoodPW As Boolean
Public ECell As Range
Private Sub Worksheet_Change(ByVal Target As Range)
Dim myR As Long
If GoodPW And Target.Address = ECell.Address Then
Target.Parent.Unprotect myPW
ECell.Locked = True
With Worksheets("Record Sheet")
myR = .Cells(Rows.Count, 1).End(xlUp)(2).Row
.Cells(myR, 1).Value = Now
.Cells(myR, 2).Value = Application.UserName
.Cells(myR, 3).Value = ECell.Value
End With
Target.Parent.Protect myPW
End If
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Set ECell = Range("C4")
If Target.Address < ECell.Address Then Exit Sub
If MsgBox("Do you want toeditcell" & ECell.Address(False, False) & "?", vbYesNo) = vbNo Then Exit
Sub
On Error GoTo BadPW
myPW = Application.InputBox("What is the password?")
GoodPW = False
Target.Parent.Unprotect myPW
GoodPW = True
ECell.Locked = False
Target.Parent.Protect myPW

Exit Sub
BadPW:
MsgBox "That password was incorrect...."

End Sub

"SNM" wrote in message

...

I need some help withprotectedcells. I have many cells with
formulas. All of them areprotected. However, sometimes I cannot
accept the value calculated by theformulaand in such cases, I need
to enter the value manually. To do this, I want toeditthecellby
using a password. Different users will be entering the value manually
so if possible I would like to have a recording system of the user
name. Also after the value is entered, thecellshould beprotected
again. Is this too ambitious? I would really appreciate a prompt
response on this matter. Thanking in advance.