#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 38
Default conditional unlock

Is there a way to unlock a cell dependant on values entered in another
(unlocked) cell?

Excell 2003
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default conditional unlock

Hi,

Right click the sheet tab, view code and paste this in

Private Sub Worksheet_Change(ByVal Target As Range)
If Range("A1").Value = "lock" Then
ActiveSheet.Unprotect
Range("B1").Locked = True
ActiveSheet.Protect

Else
ActiveSheet.Unprotect
Range("B1").Locked = False
ActiveSheet.Protect
End If
End Sub

Mike

"johnsail" wrote:

Is there a way to unlock a cell dependant on values entered in another
(unlocked) cell?

Excell 2003

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 38
Default conditional unlock

Hi Mike,
First thanks for quick response.

Am new to macros / VB so don't really understand how to use your info. Also
don't know if my question was clear so . . . .

3 cells in worksheet. A1 B1 C1.
A1 unlocked. B1 and C1 both locked.

Enter cat in A1 and need to unlock B1 so data can be entered.
Enter dog in A1 and need to unlock C1 so data can be entered.

John



"Mike H" wrote:

Hi,

Right click the sheet tab, view code and paste this in

Private Sub Worksheet_Change(ByVal Target As Range)
If Range("A1").Value = "lock" Then
ActiveSheet.Unprotect
Range("B1").Locked = True
ActiveSheet.Protect

Else
ActiveSheet.Unprotect
Range("B1").Locked = False
ActiveSheet.Protect
End If
End Sub

Mike

"johnsail" wrote:

Is there a way to unlock a cell dependant on values entered in another
(unlocked) cell?

Excell 2003

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default conditional unlock

Assuming you have A1:A10 unlocked and all other cells locked this event code
will unlock adjacent cells in column B.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Intersect(Target, Me.Range("A1:A10")) Is Nothing Then Exit Sub
On Error GoTo enditall
Application.EnableEvents = False
If Target.Value < "" Then
ActiveSheet.Unprotect Password:="justme"
With Target.Offset(0, 1)
.Locked = False
End With
End If
enditall:
Application.EnableEvents = True
ActiveSheet.Protect Password:="justme"
End Sub

This is sheet event code. Right-click on the sheet tab and "View Code".

Copy/paste into that sheet module.


Gord Dibben MS Excel MVP

On Mon, 22 Oct 2007 04:02:01 -0700, johnsail
wrote:

Is there a way to unlock a cell dependant on values entered in another
(unlocked) cell?

Excell 2003


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
Unlock VBE Brettjg Excel Discussion (Misc queries) 3 October 16th 07 04:45 PM
Unlock cells Siva Excel Discussion (Misc queries) 1 April 26th 07 04:04 PM
How to Unlock K New Users to Excel 4 February 2nd 07 09:45 PM
how do i password protect an .xls file? how do i unlock it for automation. e.g. want to unlock and access a .xls from another .xls macro. Daniel Excel Worksheet Functions 1 June 24th 05 02:59 PM
how to unlock a workbook Mellissa Excel Worksheet Functions 1 March 18th 05 02:17 PM


All times are GMT +1. The time now is 09:58 PM.

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

About Us

"It's about Microsoft Excel"