close

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 amp; Regrds,
New Excel User.--
abcdexcel
------------------------------------------------------------------------
abcdexcel's Profile: www.excelforum.com/member.php...oamp;userid=30021
View this thread: www.excelforum.com/showthread...hreadid=497330Happy 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(quot;A1quot;) = quot;yourvaluequot; Then
'unprotect/unlock cell
Range(quot;A1quot;).Select
ActiveSheet.Unprotect
Selection.Locked = False
Else
'lock and protect
Range(quot;A1quot;).Select
ActiveSheet.Unprotect
Selection.Locked = False
End if

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

idea...?Dannyquot;abcdexcelquot; wrote:

gt;
gt; Hi
gt;
gt; I have a cell in which drop down list box is applied. Depending upon
gt; the data in that cell, code needed to lock (protect / unprotect) the
gt; adjacent cell.
gt;
gt; Thnks amp; Regrds,
gt; New Excel User.
gt;
gt;
gt; --
gt; abcdexcel
gt; ------------------------------------------------------------------------
gt; abcdexcel's Profile: www.excelforum.com/member.php...oamp;userid=30021
gt; View this thread: www.excelforum.com/showthread...hreadid=497330
gt;
gt;


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 amp; Regards,
Aamir--
abcdexcel
------------------------------------------------------------------------
abcdexcel's Profile: www.excelforum.com/member.php...oamp;userid=30021
View this thread: www.excelforum.com/showthread...hreadid=497330If you know the range, you can specify in the example given
Range(quot;startquot;,quot;endquot;)

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 Functionquot;abcdexcelquot; wrote:

gt;
gt; Wish U the same.
gt;
gt; Thanks for replying. That will certaining help me.
gt;
gt; But I need a code for the entire column / row. A code with a loop or
gt; something like it.
gt;
gt; Thanks amp; Regards,
gt; Aamir
gt;
gt;
gt; --
gt; abcdexcel
gt; ------------------------------------------------------------------------
gt; abcdexcel's Profile: www.excelforum.com/member.php...oamp;userid=30021
gt; View this thread: www.excelforum.com/showthread...hreadid=497330
gt;
gt;

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()