Lock Cell After Data is Entered on Particular Cell

M

Moideen

We are maintaing an excel sheet for expense details, After Entering th
data on Amount Coloumn Need to Lock The Amount Coloumn with Password.
Please help me.

Coloumn 1 Coloumn 2 Coloumn 3

Date Item Name Amoun
 
W

WoolyBully

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


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.
 
G

Gord Dibben

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
 
C

CellShocked

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


Still seems quite vulnerable.
 
G

Gord Dibben

Still seems quite vulnerable.

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
 
M

Moideen

'Gord Dibben[_2_ said:
;1603079']First...........select all cells on sheet and format them t
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


On Sun, 24 Jun 2012 12:00:21 +0000, Moideen
We are maintaing an excel sheet for expense details, After Enterin 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-

Dear Gord ,

Thank you very much, It's Function working well, But i unprotected th
work sheet with the password of "justme" and excel opening time nee
auto protection if i forgot to protect the sheet before excel closin
time.
your kindly help is highly appreciate
 
G

Gord Dibben

Dear Gord ,

Thank you very much, It's 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

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
 
M

Moideen

'Gord Dibben[_2_ said:
;1603139']On Mon, 25 Jun 2012 12:29:45 +0000, Moideen
Dear Gord ,

Thank you very much, It's 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-

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

Dear Gord,

Thank you once again for your quick response,We are not facing thes
types of issues, Because this is not a highly important file
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top