ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Data Entry and Protection (https://www.excelbanter.com/excel-programming/406373-re-data-entry-protection.html)

tiptoe

Data Entry and Protection
 
On Feb 20, 3:10 am, Ken Johnson wrote:
Maybe something like this...

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Sheet1.Unprotect "tiptoe"
Dim rgCell As Range
For Each rgCell In Range("B2:C11")
If rgCell.Value = "" Then
rgCell.Locked = False
Else: rgCell.Locked = True
End If
Next
Sheet1.Protect "tiptoe"
End Sub

When the workbook is saved each cell in the range of cells where data
is to be entered by all the different other users (Sheet1!B2:C11 in
the sample code) is locked if not blank and unlocked if blank. The
sheet is protected with the password "tiptoe"

The code has to be pasted into the ThisWorkbook code module.

Ken Johnson


Ken,
Thanks, looking good.

Regards,
tiptoe

Ken Johnson

Data Entry and Protection
 
You're welcome tiptoe.
Thanks for the feedback and the great rating.

Ken Johnson


All times are GMT +1. The time now is 10:57 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com