A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Re : How to lock a cell once the value is entered



 
 
Thread Tools Display Modes
  #1  
Old June 22nd, 2009, 03:52 PM posted to microsoft.public.excel.worksheet.functions
Andy
external usenet poster
 
Posts: 941
Default Re : How to lock a cell once the value is entered

Hi - I want to lock the cell once the value is entered by the user. i.e. for
example, if somebody enters 1 as value in a cell, it should not allow the
user to change the status later unless it is approved. Is it possible!
  #2  
Old June 22nd, 2009, 04:35 PM posted to microsoft.public.excel.worksheet.functions
Don Guillett
external usenet poster
 
Posts: 6,167
Default How to lock a cell once the value is entered

Assuming your sheet is protected and cells are UNlocked.
right click sheet tabview codeinsert this

Private Sub Worksheet_Change(ByVal Target As Range)
ActiveSheet.Unprotect
Target.Locked = True
ActiveSheet.Protect
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Andy" wrote in message
...
Hi - I want to lock the cell once the value is entered by the user. i.e.
for
example, if somebody enters 1 as value in a cell, it should not allow the
user to change the status later unless it is approved. Is it possible!


  #3  
Old June 22nd, 2009, 08:44 PM posted to microsoft.public.excel.worksheet.functions
Gord Dibben
external usenet poster
 
Posts: 20,252
Default Re : How to lock a cell once the value is entered

With VBA event code.

Are you willing to give that a try?

Assuming all cells in Column A are set to unlocked under
FormatCellsProtectionUnlocked and the sheet is protected with a password
of "justme"(no quotes)

This code will lock each cell in column A when a value is entered in that
cell.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo enditall
Application.EnableEvents = False
If Target.Cells.Column = 1 Then
ActiveSheet.Unprotect Password:="justme"
If Target.Value "" Then
Target.Locked = True
End If
End If
enditall:
Application.EnableEvents = True
ActiveSheet.Protect Password:="justme"
End Sub

Right-click on the sheet tab and "View Vode"

Copy/paste into that module.

Alt + q to return to Excel window.


Gord Dibben MS Excel MVP

On Mon, 22 Jun 2009 07:52:02 -0700, Andy
wrote:

Hi - I want to lock the cell once the value is entered by the user. i.e. for
example, if somebody enters 1 as value in a cell, it should not allow the
user to change the status later unless it is approved. Is it possible!


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:41 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.