LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Conditional Cell Locking/Unlocking


Could someone please help!?

I am afraid VBA is a mystery to me and I just don't seem to be able t
get to grips with it - anyway, here is what I am trying to do:

Lock cells conditionally using Select Case but my attempt below jus
doesn't work - my condition is as follows

If cell $C$1 is not equal to "Yes" then lock the cel
ranges as listed:

Private Sub Worksheet_Change(ByVal Target As Range)
Select Case Target.Address

Case "$C$1" < "Yes"
ActiveSheet.Unprotect ("MyPassword")
Range("$C$4:$C$7,$C$12:$C$15,$C$20:$C$23,$C$28:$C$ 31,$C$36:$C$39").Locke
= True
ActiveSheet.Protect ("MyPassword")

Case "$D$1" < "Yes"
ActiveSheet.Unprotect ("MyPassword")
Range("$D$4:$D$7,$D$12:$D$15.$D$20:$D$23:,$D$28:$D $31,$D$36:$D$39").Locke
= True
ActiveSheet.Protect ("MyPassword")

Case "$E$1" < "Yes"
ActiveSheet.Unprotect ("MyPassword")
Range("$E$4:$E$7,$E$12:$E$15.$E20:$E$23:,$E$28:$E$ 31,$E$36:$E$39").Locke
= True
ActiveSheet.Protect ("MyPassword")

Case "$F$1" < "Yes"
ActiveSheet.Unprotect ("MyPassword")
Range("$F$4:$F$7,$F$12:$F$15.$F$20:$F$23:,$F$28:$F $31,$F$36:$F$39").Locke
= True
ActiveSheet.Protect ("MyPassword")

Case "$G$1" < "Yes"
ActiveSheet.Unprotect ("MyPassword")
Range("$G$4:$G$7,$G$12:$G$15.$G$20:$G$23:,$G$28:$G $31,$G$36:$G$39").Locke
= True
ActiveSheet.Protect ("MyPassword")

Case Else
Exit Sub

End Select
End Sub

If possible I would also like to Unlock these cells if $C$1 equal t
"Yes"

I would be grateful for any help - just like a cry from th
wilderness!

Deele

--
deele
-----------------------------------------------------------------------
deelee's Profile: http://www.excelforum.com/member.php...fo&userid=3486
View this thread: http://www.excelforum.com/showthread.php?threadid=54614

 
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
Locking/Unlocking based on another cell value Iriemon Excel Worksheet Functions 0 March 27th 08 02:47 PM
locking and unlocking worksheets adam Excel Worksheet Functions 6 October 31st 07 05:31 PM
Unlocking and locking a specific cell Reggie Excel Programming 2 December 22nd 05 12:39 AM
Locking/unlocking cells Ian Coates Excel Programming 1 February 3rd 04 04:04 PM
locking and unlocking a row of data based on whats entered in a cell Joshua F. Excel Programming 2 December 4th 03 06:11 PM


All times are GMT +1. The time now is 09:05 AM.

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"