Excel - Lock Cell After Data is Entered on Particular Cell
Asked By Moideen on 24-Jun-12 08:00 AM
We are maintaing an excel sheet for expense details, After Entering the
data on Amount Coloumn Need to Lock The Amount Coloumn with Password.
Please help me.
Coloumn 1 Coloumn 2 Coloumn 3
Date Item Name Amount
WoolyBully replied to Moideen on 24-Jun-12 09:55 AM
Unlock cell, add data, re-lock cell.
All has to be by code. No auto-function for this. You must visit the
Gord Dibben replied to Moideen on 24-Jun-12 10:08 AM
First...........select all cells on sheet and format them to unlocked.
Add this event code to the worksheet module.
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo enditall
Application.EnableEvents = False
If Target.Cells.Column = 3 Then
n = Target.Row
If Me.Range("C" & n).Value <> "" Then
Me.Range("C" & n).Locked = True
Application.EnableEvents = True
When you enter a value in column C that cell will become locked for
CellShocked replied to Gord Dibben on 24-Jun-12 10:31 AM
Still seems quite vulnerable.
Gord Dibben replied to CellShocked on 24-Jun-12 01:19 PM
In what manner other than the weakness of Excel's internal security
which is always the issue.
OP can lock the project from viewing so's users cannot see the
GS replied to Moideen on 24-Jun-12 09:26 PM
How would the user edit an incorrect entry in the amount column?
Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup!
Moideen replied to Gord Dibben on 25-Jun-12 08:29 AM
'Gord Dibben[_2_ Wrote:
Dear Gord ,
Thank you very much, it is Function working well, But i unprotected the
work sheet with the password of "justme" and excel opening time need
auto protection if i forgot to protect the sheet before excel closing
your kindly help is highly appreciated
Gord Dibben replied to Moideen on 25-Jun-12 04:16 PM
Copy/paste this event code to Thisworkbook module.
Private Sub Workbook_BeforeClose(Cancel As Boolean)
NOTE: as others have pointed out, Excel's internal security is quite
weak and protection of cells and sheets will serve only to prevent
accidental overwriting of formulas or data.
A user determined to change data can easily crack the password
GS also asked "how will user correct a mistake in data entry if cells
What will you do if users do not enable VBA when they open the
Have you considered these issues?
Moideen replied to Gord Dibben on 26-Jun-12 06:08 AM
'Gord Dibben[_2_ Wrote:
Thank you once again for your quick response,We are not facing these
types of issues, Because this is not a highly important file.