View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Getting around Protected Worksheet (number format)

Not sure I totally follow, if the sheet is protected how does the "P13" cell
end up being changed. Perhaps in the event with code you could unprotect,
write the new value, then re-protect Or maybe leave your cell(s) unlocked.

or write to the other sheet

If Target.Address = Range("P13").Address Then
worksheets("Sheet2").Range("H13").Value = Now
End If

or use the CodeName if "Sheet2" might get renamed
Sheet2.Range("H13").Value = Now

Regards,
Peter T


"Al 305" wrote in message
...
Hi..
I have this command which put a timestamp on a cell every time you
write something in another cell.. I then use a NumberFormat command to
put the timestamp in H:MM.. But when i protect my worksheet (this
Worsheet Needs to be protected), it gives an error.. I am trying to
get a way around it.. My first idea is to have an other worksheet that
would =sheet1! .. This worsheet (2) wouldnt be protected, so the
number format macro would work.. My problem is that since the worsheet
(2) is not the active, it does not recalculate the timestamp
function.. Here is the Command:

Private Sub Worksheet_Activate()
Call Recalculate
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = Range("P13").Address Then
Range("H13").Value = Now
End If

If Target.Address = "$H$13" Then
Target.NumberFormat = "h:mm"
End If
End Sub

I am sure that there are different ways to solve this problem..Anybody
would know a way around this?