Two timestamps in one sheet

Dscalf1

New Member
Joined
Jun 14, 2015
Messages
41
Hello All,

I am trying to get two timestamps in one sheet. I have one range of cells (R6:AF6) and when someone types in any information in any of this range of cells I want a time stamp to show up in cell BH6. Now exactly the same I have this range of cells (AJ6:AX6) and when anyone types on any of these cells I want a timestamp to show up in cell BJ6.

I have this code and it works great for the first part if any cells are entered it shows a timestamp in cell BH 6, however I tried to copy and paste this code to do the second set and it wont work.... Any ideas?

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Column = 18 Or Target.Column > 35 Then Exit Sub
    Application.EnableEvents = False
    Cells(Target.Row, 61) = Now
    Application.EnableEvents = True
End Sub
 
Changed it to this... Worked for two rows then it gave me an error and stopped working


Code:
Private Sub Worksheet_Change(ByVal Target As Range)





   If Not Intersect(Target, Range("J6:X75")) Is Nothing Then
   ActiveSheet.Unprotect "Bakery"
      Application.EnableEvents = False
      Cells(Target.Row, 52) = Now
      Application.EnableEvents = True
   ElseIf Not Intersect(Target, Range("AB6:AP75")) Is Nothing Then
      Application.EnableEvents = False
      Cells(Target.Row, 54) = Now
      Application.EnableEvents = True
       
      ActiveSheet.Protect "Bakery", True, True
       
   End If
   
End Sub
 
Upvote 0

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
You only have two different IF statements, and you are unprotecting it in one, and re-protecting in the other, but neither one has both, so both are incomplete.

Try:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)

   If Not Intersect(Target, Range("J6:X75")) Is Nothing Then
      ActiveSheet.Unprotect "Bakery"
      Application.EnableEvents = False
      Cells(Target.Row, 52) = Now
      Application.EnableEvents = True
      ActiveSheet.Protect "Bakery", True, True
   ElseIf Not Intersect(Target, Range("AB6:AP75")) Is Nothing Then
      ActiveSheet.Unprotect "Bakery"
      Application.EnableEvents = False
      Cells(Target.Row, 54) = Now
      Application.EnableEvents = True
      ActiveSheet.Protect "Bakery", True, True
   End If
   
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top