A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
You are amazing Hans!!!
Thank you for the prompt reply and for all your help.
Kind Regards
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello,
I have a spreadsheet that is automatically protected after data entry. Kind folks here helped me put in a procedure for protecting and unprotecting data sheet after data entry.
Now, I would like to populate cells E1:E14 if the adjacent cell A1:A14 is populated. But since the worksheet protects itself after data-entry, this is proving to be a bit of a trouble. Can someone please help?
Many Thanks in advance
Option Explicit
Private Sub Workbook_BeforeClose(Cancel As Boolean)
LockUsed
Me.Save
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
LockUsed
End Sub
Sub LockUsed()
Dim trg As Range
Dim rng As Range
With Worksheets("Sheet1")
.Unprotect Password:="secret"
Set trg = Worksheets("Sheet1").Range("A1:C14")
On Error Resume Next
Set rng = trg.SpecialCells(xlCellTypeConstants)
If Not rng Is Nothing Then
rng.Locked = True
End If
Set rng = Nothing
Set rng = trg.SpecialCells(xlCellTypeFormulas)
If Not rng Is Nothing Then
rng.Locked = True
End If
.Protect Password:="secret"
End With
End Sub
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Count > 1 Then Exit Sub
If Not Intersect(Range("A1:A14"), .Cells) Is Nothing Then
Application.EnableEvents = False
If IsEmpty(.Value) Then
.Unprotect Password:="secret"
.Offset(0, 4).ClearContents
Else
With .Offset(0, 4)
.Unprotect Password:="secret"
.NumberFormat = "dd mmm yyyy hh:mm:ss"
.Value = Now
End With
End If
Application.EnableEvents = True
End If
End With
End Sub
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
You are amazing Hans!!!
Thank you for the prompt reply and for all your help.
Kind Regards
This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.
Comments have been turned off. Learn more