-
March 9th, 2009, 05:47 PM
#1
unlock cell based on content from another cell
I am trying to build a report form for my local volunteer fire department.
I need to be able to unlock cells g12 and af12 based on the content of cell e9. I am not a code writer but here is what I have and it is not working.
By the way the whole sheet is protected and only cells needing to be edited are formated to be unlocked. NO PASSWORD
Private Sub Worksheet_Change(ByVal Target As Range)
If Range("E9") = "WF-" Then
Range("G12, AF12").Locked = False
Else: Range("G12,AF12").ClearContents
End If
Am I missing something or do I just have it too simple.
I tried to run this code but I get a "Unable to set the locked property of the Range class" if E9="WF-" Otherwise, -IF e9 does not ="WF-" I come up with and error that says "the cell or chart you are trying to change is protected and therefore read-only." "To modify a protected cell or chart, first remove protection using the unprotect sheet command...)
-
March 9th, 2009, 09:06 PM
#2
Re: unlock cell based on content from another cell
You probably connect using an older method for a different version of Office. Show more of your code, and the Office version used.
-
March 9th, 2009, 10:15 PM
#3
Re: unlock cell based on content from another cell
Hi, I am using office 07 but the report form will be run on the 03 version. I am using vb 6.3 (comes with office 07)
This is all of the code that I have for this particular need. Will I need a more complex code?
Here is another code that I tried but also without success.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("e9")) Is Nothing Then
Select Case Target.Cells(1, 1).Value
Case "WF-"
ActiveSheet.Unprotect PW
Application.EnableEvents = False
Range("G12").MergeArea.Locked = False
Application.EnableEvents = True
ActiveSheet.Protect PW
End Select
End If
Last edited by 2funny4words; March 9th, 2009 at 10:17 PM.
-
March 9th, 2009, 10:39 PM
#4
Re: unlock cell based on content from another cell
1) Use CODE TAGS so we can read your mess...
2) You're using VBA, so you should just record a MACRO of what you want to do, and then look at the code.
-
March 11th, 2009, 06:00 PM
#5
Re: unlock cell based on content from another cell
There is an almost similar situation here: http://www.codeguru.com/forum/showthread.php?t=468069
See Post#8
Marketing our skills - please participate in the survey and share your insights
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|