How to Lock cells and have them be unlocked based on a cell being

H

hak0828

To anybody kind enough to take the time to read my post,

I am working on a very simple and basic excel workbook in which I have
many work sheets for different clients with a questionnaire that each
client must complete


One of the questions requires either it be left blank or marked with
an "x".


The question is located in column S and applies to all account of the
clients. If an "x' is placed, then I would like the three following
columns to be unlocked (column T, U, V) so that they can be answered.

Therefore if row 12 has S12 marked with an "x",then T12:V12 will be
unlocked. However if S13 is left blank then S13:V13 are left locked and so
on.....


Is there anybody who can help me.


Thank you so much for your time,


Hakan

Please email me (e-mail address removed) for any suggestions.

All the best
 
R

Ron de Bruin

hi hak0828

You can use the change event in the sheet module
http://www.rondebruin.nl/code.htm

If you change a cell in S and it is a "x" it will unprotect the sheet
unlock the three cells and protect the sheet.
If it is not a "x" it lock the cells

I not use a password in this example

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Column = 19 Then '= column S

ActiveSheet.Unprotect
If LCase(Target.Value) = "x" Then
Cells(Target.Row, "T").Resize(, 3).Locked = False
Else
Cells(Target.Row, "T").Resize(, 3).Locked = True
End If
ActiveSheet.Protect

End If
End Sub
 
H

hak0828

Thank you for your reply Ron,

Unfortunately I failed to mention that I am very unfamiliar with running
macros.

As far as I am concerned, I put the code u gave me into module 2 of a
worksheet, since i am already running another macro in module 1.

i tried to run the macro and it did not do anything.

Please let me know what I must do for this code to run effectively

all the best,

Hakan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top