Validation & Protection

  • Thread starter Thread starter abcdexcel
  • Start date Start date
A

abcdexcel

Hi

I have a cell in which drop down list box is applied. Depending upon
the data in that cell, code needed to lock (protect / unprotect) the
adjacent cell.

Thnks & Regrds,
New Excel User.
 
Happy new year.

If you need an action to occur on a condition, you'll need an IF statement.
Because you want to change a screen option, you'll need some code.

So what we do is use an event to check teh value and take action

Something like:

If Range("A1") = "yourvalue" Then
'unprotect/unlock cell
Range("A1").Select
ActiveSheet.Unprotect
Selection.Locked = False
Else
'lock and protect
Range("A1").Select
ActiveSheet.Unprotect
Selection.Locked = False
End if

'reprotect sheet
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

idea...?


Danny
 
Wish U the same.

Thanks for replying. That will certaining help me.

But I need a code for the entire column / row. A code with a loop or
something like it.

Thanks & Regards,
Aamir
 
If you know the range, you can specify in the example given
Range("start","end")

If you want to loop through cells, that can be done with a FOR NEXT loop -
but I'd need to know which cells you want to protect...
Then you call functions to protect ot unprotect:

Function UnprotectCell()
'unprotect/unlock cell
ActiveCell.Select
ActiveSheet.Unprotect
Selection.Locked = False
End Function

Function ProtectCell()
'unprotect/unlock cell
ActiveCell.Select
ActiveSheet.Unprotect
Selection.Locked = True
End Function
 

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

Back
Top