View Single Post
  #2   Report Post  
Sepeteus Jedermann Sepeteus Jedermann is offline
Junior Member
 
Posts: 18
Wink

Quote:
Originally Posted by Judy P. View Post
I have been copying and pasting pieces of codes, when I finally get it to work, I do something and it stops working, recently, I added Range Protection (passwords).

Objective:
I would like for cell B4 to update/timestamp the current date and time when any of the cells within the range "Data_UpdatesUS" changes. I would also like for cell C4 to update if the range "Data_UpdatesEU" changes, and so on for IN, CN and BR.

To understand, IN=India, CN=China, etc. The range of cells represents salary information for each of the employee types in column A.

I have Range Protection (password protected, let's say 1234US) applied to each of the named ranges. I also have worksheet protection (password protected, let's say 1234).

This code works if the sheet is NOT protected at all:

Private Sub Worksheet_Change(ByVal Target As Range)
If Not (Application.Intersect(Target, Range("Data_UpdatesUS")) Is Nothing) Then
Application.EnableEvents = False
Application.EnableEvents = True
End If
If Not (Application.Intersect(Target, Range("Data_UpdatesEU")) Is Nothing) Then
Application.EnableEvents = False
Range("C4") = Now()
Application.EnableEvents = True
End If
If Not (Application.Intersect(Target, Range("Data_UpdatesIN")) Is Nothing) Then
Application.EnableEvents = False
Range("D4") = Now()
Application.EnableEvents = True
End If
If Not (Application.Intersect(Target, Range("Data_UpdatesCN")) Is Nothing) Then
Application.EnableEvents = False
Range("E4") = Now()
Application.EnableEvents = True
End If
If Not (Application.Intersect(Target, Range("Data_UpdatesBR")) Is Nothing) Then
Application.EnableEvents = False
Range("F4") = Now()
Application.EnableEvents = True
End If
End Sub

However, when I add the protection, it stops working.

Is there anyone who can help???
Hi,

try to do the worksheet protection by VBA-code rather than manually.
Pay attention to Worksheet.protect methods "Userinterface only" property.

UserInterfaceOnly - Optional - Variant - True to protect the user interface, but not macros. If this argument is omitted, protection applies both to macros and to the user interface.

If UserInterfaceOnly = True, then users can't change values at worksheet but your code can. Even if the worksheet is protected.

***