Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 55
Default Auto-lock a cell once it's updated

Hi.

I have a shared workbook that is used by two processors. On column A I have
a drop down that allows the processors to select Yes or No. I would like the
cell that they update to automatically lock by not allowing the processors to
go back and change what they already selected. If they try to change the
info, I would like it to prompt a password request in order to make a change
on that cell. If this is possible please let me know.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default Auto-lock a cell once it's updated

Sheet event code..........to be pasted into the sheet module.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo enditall
Application.EnableEvents = False
If Target.Cells.Column = 1 Then
With Me
.Unprotect Password:="justme" 'password to suit
n = Target.Row
If .Range("A" & n).Value < "" Then
.Range("A" & n).Locked = True 'adjust the "A" if you wanted
'column B locked
End If
End With
End If
enditall:
Application.EnableEvents = True
Me.Protect Password:="justme"
End Sub

When happy with code, hit ToolsVBAProject Properties and protect the code
from view.

Alt + q to return to Excel.


Gord Dibben MS Excel MVP

On Wed, 5 May 2010 11:54:01 -0700, Oscar
wrote:

Hi.

I have a shared workbook that is used by two processors. On column A I have
a drop down that allows the processors to select Yes or No. I would like the
cell that they update to automatically lock by not allowing the processors to
go back and change what they already selected. If they try to change the
info, I would like it to prompt a password request in order to make a change
on that cell. If this is possible please let me know.

Thanks


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 55
Default Auto-lock a cell once it's updated

Thanks for the quick response. I used the code and it works; however, I
noticed that when I try to update the next row on column A or any other field
outside of column A, it ask me to unprotect the worksheet using the password.
Would it be possible to only ask to unprotect the sheet if I tried to go back
and delete or update a row I already updated under column A?

Thanks

"Gord Dibben" wrote:

Sheet event code..........to be pasted into the sheet module.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo enditall
Application.EnableEvents = False
If Target.Cells.Column = 1 Then
With Me
.Unprotect Password:="justme" 'password to suit
n = Target.Row
If .Range("A" & n).Value < "" Then
.Range("A" & n).Locked = True 'adjust the "A" if you wanted
'column B locked
End If
End With
End If
enditall:
Application.EnableEvents = True
Me.Protect Password:="justme"
End Sub

When happy with code, hit ToolsVBAProject Properties and protect the code
from view.

Alt + q to return to Excel.


Gord Dibben MS Excel MVP

On Wed, 5 May 2010 11:54:01 -0700, Oscar
wrote:

Hi.

I have a shared workbook that is used by two processors. On column A I have
a drop down that allows the processors to select Yes or No. I would like the
cell that they update to automatically lock by not allowing the processors to
go back and change what they already selected. If they try to change the
info, I would like it to prompt a password request in order to make a change
on that cell. If this is possible please let me know.

Thanks


.

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default Auto-lock a cell once it's updated

I guess I assumed you would Unlock ALL cells on the worksheet prior to
adding the code.

Apologies for not pointing that out.

If you did not then go back and start again.

Unprotect the sheet.

Select all cells and FormatCellsProtection......uncheck Locked.

Now add the code.

As users select from yes/no dropdown that cell will become locked.

To edit you must enter password to unprotect.


Gord



On Thu, 6 May 2010 13:08:01 -0700, Oscar
wrote:

Thanks for the quick response. I used the code and it works; however, I
noticed that when I try to update the next row on column A or any other field
outside of column A, it ask me to unprotect the worksheet using the password.
Would it be possible to only ask to unprotect the sheet if I tried to go back
and delete or update a row I already updated under column A?

Thanks

"Gord Dibben" wrote:

Sheet event code..........to be pasted into the sheet module.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo enditall
Application.EnableEvents = False
If Target.Cells.Column = 1 Then
With Me
.Unprotect Password:="justme" 'password to suit
n = Target.Row
If .Range("A" & n).Value < "" Then
.Range("A" & n).Locked = True 'adjust the "A" if you wanted
'column B locked
End If
End With
End If
enditall:
Application.EnableEvents = True
Me.Protect Password:="justme"
End Sub

When happy with code, hit ToolsVBAProject Properties and protect the code
from view.

Alt + q to return to Excel.


Gord Dibben MS Excel MVP

On Wed, 5 May 2010 11:54:01 -0700, Oscar
wrote:

Hi.

I have a shared workbook that is used by two processors. On column A I have
a drop down that allows the processors to select Yes or No. I would like the
cell that they update to automatically lock by not allowing the processors to
go back and change what they already selected. If they try to change the
info, I would like it to prompt a password request in order to make a change
on that cell. If this is possible please let me know.

Thanks


.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel cells randomly don't get updated unless each cell is updated Lost in Excel Excel Discussion (Misc queries) 5 September 29th 08 06:56 PM
auto caps lock ramzi Excel Discussion (Misc queries) 2 July 25th 08 09:53 PM
I have lock a wookbook but one cell does not want to lock it Mimi Excel Discussion (Misc queries) 2 January 21st 07 10:59 PM
I have lock a wookbook but one cell does not want to lock it Mimi Excel Discussion (Misc queries) 1 January 21st 07 09:44 AM
Lock or Unlock cell references in a formula for auto fill purposes David P. Excel Discussion (Misc queries) 2 June 6th 05 11:18 PM


All times are GMT +1. The time now is 03:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"