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
--
Moideen
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
programming sub-group.
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
ActiveSheet.Unprotect Password:="justme"
n = Target.Row
If Me.Range("C" & n).Value <> "" Then
Me.Range("C" & n).Locked = True
End If
End If
enditall:
ActiveSheet.Protect Password:="justme"
Application.EnableEvents = True
End Sub
When you enter a value in column C that cell will become locked for
editing.
Gord
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
password.
Gord
GS replied to Moideen on 24-Jun-12 09:26 PM
How would the user edit an incorrect entry in the amount column?
--
Garry
Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
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
time.
your kindly help is highly appreciated
--
Moideen
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)
Sheets("yoursheetname").Protect Password:="justme"
End Sub
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
protection.
GS also asked "how will user correct a mistake in data entry if cells
are locked"?
What will you do if users do not enable VBA when they open the
workbook?
Have you considered these issues?
Gord
Moideen replied to Gord Dibben on 26-Jun-12 06:08 AM
'Gord Dibben[_2_ Wrote:
Dear Gord,
Thank you once again for your quick response,We are not facing these
types of issues, Because this is not a highly important file.
--
Moideen