View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
junoon junoon is offline
external usenet poster
 
Posts: 13
Default Locking multiple Cell Ranges with TimeStamp

Hi,

I have 31 similar sheets & each sheet having 4 similar tables.

To begin with, i have Ctrl+A all the sheets, then right-clicked &
selected Protection tab, unchecked "Locked", OK.

Take for eg. 1st table:
---------------------------
I am trying to create a TO-DO list, where in column A (TO-DO), i enter
the things to do, in Column B (STATUS), i enter the "DONE" or "NOT
DONE" (Data Validation drop-down list). The Column B Range is B2:B12.

If i select "NOT DONE", the corresponding (OFFSET) cell in Column C
(STATUS
TIME) would show the Current Time & the cell would get Locked up so
that Time will not change, even if i Change Cell in Column B to "Done".

In Column D (COMPLETION TIME), i would get the Time when the TO-DO job
was completed or DONE. i.e. if i select "DONE" from the Drop-down list
in Column C, i should get the Current time in Column D cell. THIS is
not of much concern as i can use an IF statement to check if Column B
cell ="DONE".

As i said earlier, i have 31 similar Sheets & each similar Sheet has 4
similar tables, 2 ABOVE & 2 BELOW.

How can i use the Worksheet_Change event to fire on 4 ranges? That's my
main question.

Can i use something like below, which seems applicable to 1 range (
will work on 1 table only).

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Count 1 Then Exit Sub
If Not Intersect(Range("A1:A10"), .Cells) Is Nothing Then
Application.EnableEvents = False
With .Offset(0, 1)
If Me.Cells.Locked = True Then
Me.Unprotect
Me.Cells.Locked = False
End If
.NumberFormat = "dd mmm yyyy hh:mm:ss"
.Value = Now
.Locked = True
Me.Protect
End With
Application.EnableEvents = True
End If
End With
End Sub

How to do this using VBA?

Can we use:

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As
Range)

or

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal
Target As Range)


Can anyone help?